testing boolean evaluation
This commit is contained in:
parent
c46e325cf8
commit
9e30ddb060
3 changed files with 12 additions and 6 deletions
|
|
@ -55,7 +55,7 @@ op_lookup = {
|
||||||
|
|
||||||
@pointwise_sat.register(stl.AtomicPred)
|
@pointwise_sat.register(stl.AtomicPred)
|
||||||
def _(stl):
|
def _(stl):
|
||||||
return lambda x, t: x[term.id][t]
|
return lambda x, t: x[stl.id][t]
|
||||||
|
|
||||||
|
|
||||||
@pointwise_sat.register(stl.LinEq)
|
@pointwise_sat.register(stl.LinEq)
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,14 @@ ex3 = ("F[1, 0](2*A > 3)", False)
|
||||||
ex4 = ("G[1, 0](2*A > 3)", True)
|
ex4 = ("G[1, 0](2*A > 3)", True)
|
||||||
ex5 = ("(A < 0)", False)
|
ex5 = ("(A < 0)", False)
|
||||||
ex6 = ("G[0, 0.1](A < 0)", False)
|
ex6 = ("G[0, 0.1](A < 0)", False)
|
||||||
x = pd.DataFrame([[1,2], [1,4], [4,2]], index=[0,0.1,0.2],
|
ex7 = ("G[0, 0.1](C)", True)
|
||||||
columns=["A", "B"])
|
ex7 = ("G[0, 0.2](C)", False)
|
||||||
|
ex7 = ("(F[0, 0.2](C)) and (F[0, 1](2*A > 3))", True)
|
||||||
|
x = pd.DataFrame([[1,2, True], [1,4, True], [4,2, False]], index=[0,0.1,0.2],
|
||||||
|
columns=["A", "B", "C"])
|
||||||
|
|
||||||
class TestSTLRobustness(unittest.TestCase):
|
class TestSTLRobustness(unittest.TestCase):
|
||||||
@params(ex1, ex2, ex3, ex4, ex5, ex6)
|
@params(ex1, ex2, ex3, ex4, ex5, ex6, ex7)
|
||||||
def test_stl(self, phi_str, r):
|
def test_stl(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)
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ ex1_ = ('x1 > a?', stl.LinEq(
|
||||||
Symbol("a?")
|
Symbol("a?")
|
||||||
))
|
))
|
||||||
|
|
||||||
|
ex1__ = ('x1', stl.AtomicPred('x1'))
|
||||||
|
|
||||||
i1 = stl.Interval(0., 1.)
|
i1 = stl.Interval(0., 1.)
|
||||||
i1_ = stl.Interval(0., Symbol("b?"))
|
i1_ = stl.Interval(0., Symbol("b?"))
|
||||||
i2 = stl.Interval(2., 3.)
|
i2 = stl.Interval(2., 3.)
|
||||||
|
|
@ -23,9 +25,10 @@ ex3 = ('□[2,3]◇[0,1](x1 > 2)', stl.G(i2, ex2[1]))
|
||||||
ex4 = ('(x1 > 2) or ((x1 > 2) or (x1 > 2))',
|
ex4 = ('(x1 > 2) or ((x1 > 2) or (x1 > 2))',
|
||||||
stl.Or((ex1[1], ex1[1], ex1[1])))
|
stl.Or((ex1[1], ex1[1], ex1[1])))
|
||||||
ex5 = ('G[0, b?](x1 > a?)',
|
ex5 = ('G[0, b?](x1 > a?)',
|
||||||
stl.G(i1_, ex1_))
|
stl.G(i1_, ex1_[1]))
|
||||||
|
ex6 = ('◇[0,1](x1)', stl.F(i1, ex1__[1]))
|
||||||
|
|
||||||
class TestSTLParser(unittest.TestCase):
|
class TestSTLParser(unittest.TestCase):
|
||||||
@params(ex1, ex2, ex3, ex4)
|
@params(ex1, ex2, ex3, ex4, ex5, ex6)
|
||||||
def test_stl(self, phi_str, phi):
|
def test_stl(self, phi_str, phi):
|
||||||
self.assertEqual(stl.parse(phi_str), phi)
|
self.assertEqual(stl.parse(phi_str), phi)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue