simplify parser + start removing lineq code

This commit is contained in:
Marcell Vazquez-Chanlatte 2018-09-06 01:19:06 -07:00
parent 7798fe679e
commit b9b10ac835
11 changed files with 143 additions and 247 deletions

View file

@ -27,17 +27,19 @@ x = {
traces.TimeSeries([(0, 1), (0.1, 1), (0.2, 4)], domain=(0, 10)),
"y":
traces.TimeSeries([(0, 2), (0.1, 4), (0.2, 2)], domain=(0, 10)),
"AP1":
"ap1":
traces.TimeSeries([(0, True), (0.1, True), (0.2, False)], domain=(0, 10)),
"AP2":
"ap2":
traces.TimeSeries([(0, False), (0.2, True), (0.5, False)], domain=(0, 10)),
"AP3":
"ap3":
traces.TimeSeries([(0, True), (0.1, True), (0.3, False)], domain=(0, 10)),
"AP4":
"ap4":
traces.TimeSeries(
[(0, False), (0.1, False), (0.3, False)], domain=(0, 10)),
"AP5":
"ap5":
traces.TimeSeries([(0, False), (0.1, False), (0.3, True)], domain=(0, 10)),
"ap6":
traces.TimeSeries([(0, True)], domain=(0, 10)),
}
@ -47,32 +49,32 @@ def test_eval_smoke_tests(phi):
stl_eval10 = stl.boolean_eval.pointwise_sat(~stl.ast.Next(phi))
assert stl_eval9(x, 0) != stl_eval10(x, 0)
phi4 = stl.parse('~(AP4)')
phi4 = stl.parse('~ap4')
stl_eval11 = stl.boolean_eval.pointwise_sat(phi4)
assert stl_eval11(x, 0)
phi5 = stl.parse('G[0.1, 0.03](~(AP4))')
phi5 = stl.parse('G[0.1, 0.03] ~ap4')
stl_eval12 = stl.boolean_eval.pointwise_sat(phi5)
assert stl_eval12(x, 0)
phi6 = stl.parse('G[0.1, 0.03](~(AP5))')
phi6 = stl.parse('G[0.1, 0.03] ~ap5')
stl_eval13 = stl.boolean_eval.pointwise_sat(phi6)
assert stl_eval13(x, 0)
assert not stl_eval13(x, 0.4)
assert stl_eval13(x, 0.4)
phi7 = stl.parse('G(~(AP4))')
phi7 = stl.parse('G ~ap4')
stl_eval14 = stl.boolean_eval.pointwise_sat(phi7)
assert stl_eval14(x, 0)
phi8 = stl.parse('F(AP5)')
phi8 = stl.parse('F ap5')
stl_eval15 = stl.boolean_eval.pointwise_sat(phi8)
assert stl_eval15(x, 0)
phi9 = stl.parse('(AP1) U (AP2)')
phi9 = stl.parse('(ap1 U ap2)')
stl_eval16 = stl.boolean_eval.pointwise_sat(phi9)
assert stl_eval16(x, 0)
phi10 = stl.parse('(AP2) U (AP2)')
phi10 = stl.parse('(ap2 U ap2)')
stl_eval17 = stl.boolean_eval.pointwise_sat(phi10)
assert not stl_eval17(x, 0)
@ -111,7 +113,7 @@ def test_fastboolean_equiv(phi):
def test_fastboolean_smoketest():
phi = stl.parse(
'(G[0, 4](x > 0)) & ((F[2, 1](AP1)) | (AP2)) & (G[0,0](AP2))')
'(((G[0, 4] ap6 & F[2, 1] ap1) | ap2) & G[0,0](ap2))')
stl_eval = stl.fastboolean_eval.pointwise_sat(phi)
assert not stl_eval(x, 0)
@ -121,13 +123,5 @@ def test_fastboolean_smoketest():
def test_callable_interface():
phi = stl.parse(
'(G[0, 4](x > 0)) & ((F[2, 1](AP1)) | (AP2)) & (G[0,0](AP2))')
'(((G[0, 4] ap6 & F[2, 1] ap1) | ap2) & G[0,0](ap2))')
assert not phi(x, 0)
def test_implicit_validity_domain_rigid():
phi = stl.parse('(G[0, a?](x > b?)) & ((F(AP1)) | (AP2))')
vals = {'a?': 3, 'b?': 20}
stl_eval = stl.pointwise_sat(phi.set_params(vals))
oracle, order = stl.utils.implicit_validity_domain(phi, x)
assert stl_eval(x, 0) == oracle([vals.get(k) for k in order])