untimed until bug fixes
This commit is contained in:
parent
8ec0013235
commit
f04f1b3eeb
4 changed files with 11 additions and 6 deletions
|
|
@ -38,10 +38,11 @@ def _(stl):
|
||||||
|
|
||||||
|
|
||||||
def get_times(x, tau, lo=None, hi=None):
|
def get_times(x, tau, lo=None, hi=None):
|
||||||
|
domain = fn.first(x.values()).domain
|
||||||
if lo is None or lo is -oo:
|
if lo is None or lo is -oo:
|
||||||
lo = min(v.first()[0] for v in x.values())
|
lo = domain.start()
|
||||||
if hi is None or hi is oo:
|
if hi is None or hi is oo:
|
||||||
hi = max(v.last()[0] for v in x.values())
|
hi = domain.end()
|
||||||
end = min(v.domain.end() for v in x.values())
|
end = min(v.domain.end() for v in x.values())
|
||||||
hi = hi + tau if hi + tau <= end else end
|
hi = hi + tau if hi + tau <= end else end
|
||||||
lo = lo + tau if lo + tau <= end else end
|
lo = lo + tau if lo + tau <= end else end
|
||||||
|
|
@ -72,9 +73,9 @@ def eval_unary_temporal_op(phi, always=True):
|
||||||
if lo > hi:
|
if lo > hi:
|
||||||
retval = True if always else False
|
retval = True if always else False
|
||||||
return lambda x, t: retval
|
return lambda x, t: retval
|
||||||
|
f = eval_stl(phi.arg)
|
||||||
if hi == lo:
|
if hi == lo:
|
||||||
return lambda x, t: f(x, t)
|
return lambda x, t: f(x, t)
|
||||||
f = eval_stl(phi.arg)
|
|
||||||
return lambda x, t: fold(f(x, tau) for tau in get_times(x, t, lo, hi))
|
return lambda x, t: fold(f(x, tau) for tau in get_times(x, t, lo, hi))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ def _(stl):
|
||||||
for phi, tau in zip(reversed(f1(x, times)), reversed(times)):
|
for phi, tau in zip(reversed(f1(x, times)), reversed(times)):
|
||||||
if not phi:
|
if not phi:
|
||||||
state = f2(x, [tau])
|
state = f2(x, [tau])
|
||||||
|
|
||||||
if tau in t:
|
if tau in t:
|
||||||
yield state
|
yield state
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ class STLVisitor(NodeVisitor):
|
||||||
|
|
||||||
def visit_timed_until(self, _, children):
|
def visit_timed_until(self, _, children):
|
||||||
phi, _, _, (lo, hi), _, psi = children
|
phi, _, _, (lo, hi), _, psi = children
|
||||||
return env(psi, lo=lo, hi=hi) & alw(ast.Until(phi, psi), lo=0, hi=hi)
|
return env(psi, lo=lo, hi=hi) & alw(ast.Until(phi, psi), lo=0, hi=lo)
|
||||||
|
|
||||||
def visit_id(self, name, _):
|
def visit_id(self, name, _):
|
||||||
return Symbol(name.text)
|
return Symbol(name.text)
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,17 @@ ex8 = ("G[0, 0.2](C)", False)
|
||||||
ex9 = ("(F[0, 0.2](C)) and (F[0, 1](2*A > 3))", True)
|
ex9 = ("(F[0, 0.2](C)) and (F[0, 1](2*A > 3))", True)
|
||||||
ex10 = ("(A = 1) U (A = 4)", True)
|
ex10 = ("(A = 1) U (A = 4)", True)
|
||||||
ex11 = ("(A < 5) U (A = 4)", False)
|
ex11 = ("(A < 5) U (A = 4)", False)
|
||||||
|
ex12 = ("(D > 10) U (D > 10)", False)
|
||||||
|
ex13 = ("(D = 2) U[1, 20] (D = 3)", True)
|
||||||
x = {
|
x = {
|
||||||
"A": traces.TimeSeries([(0, 1), (0.1, 1), (0.2, 4)]),
|
"A": traces.TimeSeries([(0, 1), (0.1, 1), (0.2, 4)]),
|
||||||
"B": traces.TimeSeries([(0, 2), (0.1, 4), (0.2, 2)]),
|
"B": traces.TimeSeries([(0, 2), (0.1, 4), (0.2, 2)]),
|
||||||
"C": traces.TimeSeries([(0, True), (0.1, True), (0.2, False)]),
|
"C": traces.TimeSeries([(0, True), (0.1, True), (0.2, False)]),
|
||||||
|
'D': traces.TimeSeries({0.0: 2, 13.8: 3, 19.7: 2}),
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestSTLEval(unittest.TestCase):
|
class TestSTLEval(unittest.TestCase):
|
||||||
@params(ex1, ex2, ex3, ex4, ex5, ex6, ex7, ex8, ex9, ex10, ex11)
|
@params(ex1, ex2, ex3, ex4, ex5, ex6, ex7, ex8, ex9, ex10, ex11, ex12, ex13)
|
||||||
def test_eval(self, phi_str, r):
|
def test_eval(self, phi_str, r):
|
||||||
phi = stl.parse(phi_str)
|
phi = stl.parse(phi_str)
|
||||||
stl_eval = stl.boolean_eval.pointwise_sat(phi)
|
stl_eval = stl.boolean_eval.pointwise_sat(phi)
|
||||||
|
|
@ -35,7 +38,7 @@ class TestSTLEval(unittest.TestCase):
|
||||||
self.assertEqual(stl_eval2(x, 0), not r)
|
self.assertEqual(stl_eval2(x, 0), not r)
|
||||||
|
|
||||||
|
|
||||||
@params(ex1, ex2, ex3, ex4, ex5, ex6, ex7, ex8, ex9, ex10, ex11)
|
@params(ex1, ex2, ex3, ex4, ex5, ex6, ex7, ex8, ex9, ex10, ex11, ex12, ex13)
|
||||||
def test_fasteval(self, phi_str, _):
|
def test_fasteval(self, phi_str, _):
|
||||||
phi = stl.parse(phi_str)
|
phi = stl.parse(phi_str)
|
||||||
stl_eval = stl.boolean_eval.pointwise_sat(phi)
|
stl_eval = stl.boolean_eval.pointwise_sat(phi)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue