drop stl. in utils version of canonicalization
This commit is contained in:
parent
d86d155b7a
commit
6fdb0edcf6
3 changed files with 19 additions and 18 deletions
|
|
@ -5,4 +5,3 @@ from stl.parser import parse
|
||||||
from stl.synth import lex_param_project
|
from stl.synth import lex_param_project
|
||||||
from stl.boolean_eval import pointwise_sat
|
from stl.boolean_eval import pointwise_sat
|
||||||
from stl.fastboolean_eval import pointwise_satf
|
from stl.fastboolean_eval import pointwise_satf
|
||||||
from stl.smooth_robustness import smooth_robustness
|
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,13 @@ def admissible_params(phi, eps, L):
|
||||||
|
|
||||||
|
|
||||||
def symbolic_params(phi, eps, L):
|
def symbolic_params(phi, eps, L):
|
||||||
|
L = sym.Dummy("L")
|
||||||
|
eps = sym.Dummy("eps")
|
||||||
return Param(
|
return Param(
|
||||||
L=sym.Dummy("L"),
|
L=L,
|
||||||
h=sym.Dummy("h"),
|
h=sample_rate(eps, L),
|
||||||
B=sym.Dummy("B"),
|
B=sym.Dummy("B"),
|
||||||
eps=sym.Dummy("eps"),
|
eps=eps,
|
||||||
)
|
)
|
||||||
|
|
||||||
def smooth_robustness(phi, *, L=None, eps=None):
|
def smooth_robustness(phi, *, L=None, eps=None):
|
||||||
|
|
|
||||||
28
stl/utils.py
28
stl/utils.py
|
|
@ -4,7 +4,7 @@ from lenses import lens, Lens
|
||||||
import funcy as fn
|
import funcy as fn
|
||||||
import sympy
|
import sympy
|
||||||
|
|
||||||
from stl.ast import LinEq, And, Or, NaryOpSTL, F, G, Interval
|
from stl.ast import LinEq, And, Or, NaryOpSTL, F, G, Interval, Neg
|
||||||
|
|
||||||
def walk(stl, bfs=False):
|
def walk(stl, bfs=False):
|
||||||
"""Walks Ast. Defaults to DFS unless BFS flag is set."""
|
"""Walks Ast. Defaults to DFS unless BFS flag is set."""
|
||||||
|
|
@ -88,23 +88,23 @@ def set_params(stl_or_lens, val):
|
||||||
|
|
||||||
|
|
||||||
def f_neg_or_canonical_form(phi):
|
def f_neg_or_canonical_form(phi):
|
||||||
if isinstance(phi, stl.LinEq):
|
if isinstance(phi, LinEq):
|
||||||
return phi
|
return phi
|
||||||
|
|
||||||
children = [f_neg_or_canonical_form(s) for s in phi.children()]
|
children = [f_neg_or_canonical_form(s) for s in phi.children()]
|
||||||
if isinstance(phi, (stl.And, stl.G)):
|
if isinstance(phi, (And, G)):
|
||||||
children = [stl.ast.Neg(s) for s in children]
|
children = [Neg(s) for s in children]
|
||||||
children = tuple(children)
|
children = tuple(children)
|
||||||
|
|
||||||
if isinstance(phi, stl.Or):
|
if isinstance(phi, Or):
|
||||||
return stl.Or(children)
|
return Or(children)
|
||||||
elif isinstance(phi, stl.And):
|
elif isinstance(phi, And):
|
||||||
return stl.Neg(stl.Or(children))
|
return Neg(Or(children))
|
||||||
elif isinstance(phi, stl.Neg):
|
elif isinstance(phi, Neg):
|
||||||
return stl.Neg(children[0])
|
return Neg(children[0])
|
||||||
elif isinstance(phi, stl.F):
|
elif isinstance(phi, F):
|
||||||
return stl.F(phi.interval, children[0])
|
return F(phi.interval, children[0])
|
||||||
elif isinstance(phi, stl.G):
|
elif isinstance(phi, G):
|
||||||
return stl.Neg(stl.F(phi.interval, children[0]))
|
return Neg(F(phi.interval, children[0]))
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue