Skip to content

Commit

Permalink
removed old commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
karenl7 committed Aug 3, 2021
1 parent 883aa8f commit 2da6190
Showing 1 changed file with 5 additions and 57 deletions.
62 changes: 5 additions & 57 deletions src/stlcg.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ def robustness_trace(self, inputs, pscale=1, scale=-1, keepdim=True, agm=False,
for i in range(trace2.shape[1]):
RHS[:,i:,:,i] = Alw(trace1[:,i:,:])
return maxish(
minish(torch.stack([LHS, RHS], dim=-1), scale=scale, dim=-1, keepdim=False, agm=agm, distributed=distributed),
minish(torch.stack([LHS, RHS], dim=-1), scale=scale, dim=-1, keepdim=False, agm=agm, distributed=distributed),
scale=scale, dim=-1, keepdim=False, agm=agm, distributed=distributed)
elif interval[1] < np.Inf: # [a, b] where b < ∞
a = int(interval[0])
Expand Down Expand Up @@ -779,13 +779,14 @@ def __str__(self):
return "(" + str(self.subformula1) + ")" + " U " + "(" + str(self.subformula2) + ")"

class Then(STL_Formula):

def __init__(self, subformula1, subformula2, interval=None, overlap=True):
'''
subformula1 T subformula2 (ϕ U ψ)
This assumes that ϕ is eventually true before ψ becomes true.
If overlap=True, then the last time step that ϕ is true, ψ starts being true. That is, sₜ ⊧ ϕ and sₜ ⊧ ψ.
If overlap=False, when ϕ stops being true, ψ starts being true. That is sₜ ⊧ ϕ and sₜ+₁ ⊧ ψ, but sₜ ¬⊧ ψ
'''
def __init__(self, subformula1, subformula2, interval=None, overlap=True):
super(Then, self).__init__()
self.subformula1 = subformula1
self.subformula2 = subformula2
Expand Down Expand Up @@ -814,7 +815,7 @@ def robustness_trace(self, inputs, pscale=1, scale=-1, keepdim=True, agm=False,
for i in range(trace2.shape[1]):
RHS[:,i:,:,i] = Ev(trace1[:,i:,:])
return maxish(
minish(torch.stack([LHS, RHS], dim=-1), scale=scale, dim=-1, keepdim=False, agm=agm, distributed=distributed),
minish(torch.stack([LHS, RHS], dim=-1), scale=scale, dim=-1, keepdim=False, agm=agm, distributed=distributed),
scale=scale, dim=-1, keepdim=False, agm=agm, distributed=distributed)
elif interval[1] < np.Inf: # [a, b] where b < ∞
a = int(interval[0])
Expand Down Expand Up @@ -982,82 +983,29 @@ def __lt__(lhs, rhs):
assert isinstance(lhs, str) | isinstance(lhs, Expression), "LHS of LessThan needs to be a string or Expression"
assert not isinstance(rhs, str), "RHS cannot be a string"
return LessThan(lhs, rhs)
# if isinstance(lhs, Expression) and isinstance(rhs, Expression):
# return LessThan(lhs, rhs)
# elif (not isinstance(lhs, Expression)) and (not isinstance(rhs, Expression)):
# # This case cannot occur. If neither is an Expression, why are you calling this method?
# raise Exception('What are you doing?')
# elif not isinstance(rhs, Expression):
# return LessThan(lhs, rhs)
# elif not isinstance(lhs, Expression):
# assert isinstance(lhs, str) | isinstance(lhs, Expression), "LHS of LessThan needs to be a string or Expression"
# return LessThan(lhs, rhs.value)

def __le__(lhs, rhs):
assert isinstance(lhs, str) | isinstance(lhs, Expression), "LHS of LessThan needs to be a string or Expression"
assert not isinstance(rhs, str), "RHS cannot be a string"
return LessThan(lhs, rhs)
# if isinstance(lhs, Expression) and isinstance(rhs, Expression):
# return LessThan(lhs.name, rhs)
# elif (not isinstance(lhs, Expression)) and (not isinstance(rhs, Expression)):
# # This case cannot occur. If neither is an Expression, why are you calling this method?
# raise Exception('What are you doing?')
# elif not isinstance(rhs, Expression):
# return LessThan(lhs.name, rhs)
# elif not isinstance(lhs, Expression):
# assert type(lhs)==str, "LHS of LessThan needs to be a string"
# return LessThan(lhs, rhs)

def __gt__(lhs, rhs):
assert isinstance(lhs, str) | isinstance(lhs, Expression), "LHS of GreaterThan needs to be a string or Expression"
assert not isinstance(rhs, str), "RHS cannot be a string"
return GreaterThan(lhs, rhs)
# if isinstance(lhs, Expression) and isinstance(rhs, Expression):
# return GreaterThan(lhs.name, rhs)
# elif (not isinstance(lhs, Expression)) and (not isinstance(rhs, Expression)):
# # This case cannot occur. If neither is an Expression, why are you calling this method?
# raise Exception('What are you doing?')
# elif not isinstance(rhs, Expression):
# return GreaterThan(lhs.name, rhs)
# elif not isinstance(lhs, Expression):
# assert type(lhs)==str, "LHS of LessThan needs to be a string"
# return GreaterThan(lhs, rhs)

def __ge__(lhs, rhs):
assert isinstance(lhs, str) | isinstance(lhs, Expression), "LHS of GreaterThan needs to be a string or Expression"
assert not isinstance(rhs, str), "RHS cannot be a string"
return GreaterThan(lhs, rhs)
# if isinstance(lhs, Expression) and isinstance(rhs, Expression):
# return GreaterThan(lhs.name, rhs)
# elif (not isinstance(lhs, Expression)) and (not isinstance(rhs, Expression)):
# # This case cannot occur. If neither is an Expression, why are you calling this method?
# raise Exception('What are you doing?')
# elif not isinstance(rhs, Expression):
# return GreaterThan(lhs.name, rhs)
# elif not isinstance(lhs, Expression):
# assert type(lhs)==str, "LHS of LessThan needs to be a string"
# return GreaterThan(lhs, rhs)

def __eq__(lhs, rhs):
assert isinstance(lhs, str) | isinstance(lhs, Expression), "LHS of Equal needs to be a string or Expression"
assert not isinstance(rhs, str), "RHS cannot be a string"
return Equal(lhs, rhs)
# if isinstance(lhs, Expression) and isinstance(rhs, Expression):
# return Equal(lhs.name, rhs)
# elif (not isinstance(lhs, Expression)) and (not isinstance(rhs, Expression)):
# # This case cannot occur. If neither is an Expression, why are you calling this method?
# raise Exception('What are you doing?')
# elif not isinstance(rhs, Expression):
# return Equal(lhs.name, rhs)
# elif not isinstance(lhs, Expression):
# assert type(lhs)==str, "LHS of LessThan needs to be a string"
# return Equal(lhs, rhs)

def __ne__(lhs, rhs):
raise NotImplementedError("Not supported yet")

def __str__(self):
return str(self.name)

# def __repr__(self):
# return repr()
return str(self.name)

0 comments on commit 2da6190

Please sign in to comment.