def test_bounded_semantics_with_loop_optimized_depth1(self): spec = Node.from_ptr(parse_ltl_spec("G ( y <= 7 )")) # depth == 1 # it must raise exception when the bound is not feasible with self.assertRaises(ValueError): ltlspec.bounded_semantics_all_loops_optimisation_depth1( self.fsm, spec, -1) # should yield the same result (w/ opt) as regular all loops when depth is one optimized = ltlspec.bounded_semantics_all_loops_optimisation_depth1( self.fsm, spec, 5) regular = ltlspec.bounded_semantics_all_loops(self.fsm, spec, bound=5, loop=0) self.assertEqual(regular, optimized) # but not when the optim is turned off on 'all loops' regular = ltlspec.bounded_semantics_all_loops(self.fsm, spec, bound=5, loop=0, optimized=False) self.assertNotEqual(regular, optimized) # and it should only be applied when the depth is equal to one spec = Node.from_ptr(parse_ltl_spec("F G ( y <= 7 )")) # depth == 2 self.assertEqual(2, Wff.decorate(spec).depth) optimized = ltlspec.bounded_semantics_all_loops_optimisation_depth1( self.fsm, spec, 5) regular = ltlspec.bounded_semantics_all_loops(self.fsm, spec, bound=5, loop=0) self.assertNotEqual(regular, optimized)
def test_bounded_semantics_with_loop(self): # parse the ltl property spec = Node.from_ptr(parse_ltl_spec("G ( y <= 7 )")) # it must raise exception when the bound is not feasible with self.assertRaises(ValueError): ltlspec.bounded_semantics_single_loop(self.fsm, spec, -1, -2) # it must raise exception when the bound and loop are not consistent with self.assertRaises(ValueError): ltlspec.bounded_semantics_single_loop(self.fsm, spec, 5, 6) # verify that the generated problem corresponds to what is announced # without optimisation, the all loops is built as the conjunction of all # the possible 'single_loops' all_loops = ltlspec.bounded_semantics_all_loops(self.fsm, spec, 10, 0, optimized=False) acc_loops = Be.false(self.fsm.encoding.manager) for time_t in range(10): acc_loops |= ltlspec.bounded_semantics_single_loop( self.fsm, spec, 10, time_t) self.assertEqual(acc_loops, all_loops) # with optimisation, it's different all_loops = ltlspec.bounded_semantics_all_loops(self.fsm, spec, 10, 0, optimized=True) self.assertNotEqual(acc_loops, all_loops)
def test_bounded_semantics_with_loop_optimized_depth1(self): spec = Node.from_ptr(parse_ltl_spec("G ( y <= 7 )")) # depth == 1 # it must raise exception when the bound is not feasible with self.assertRaises(ValueError): ltlspec.bounded_semantics_all_loops_optimisation_depth1(self.fsm, spec, -1) # should yield the same result (w/ opt) as regular all loops when depth is one optimized = ltlspec.bounded_semantics_all_loops_optimisation_depth1(self.fsm, spec, 5) regular = ltlspec.bounded_semantics_all_loops(self.fsm, spec, bound=5, loop=0) self.assertEqual(regular, optimized) # but not when the optim is turned off on 'all loops' regular = ltlspec.bounded_semantics_all_loops(self.fsm, spec, bound=5, loop=0, optimized=False) self.assertNotEqual(regular, optimized) # and it should only be applied when the depth is equal to one spec = Node.from_ptr(parse_ltl_spec("F G ( y <= 7 )")) # depth == 2 self.assertEqual(2, Wff.decorate(spec).depth) optimized = ltlspec.bounded_semantics_all_loops_optimisation_depth1(self.fsm, spec, 5) regular = ltlspec.bounded_semantics_all_loops(self.fsm, spec, bound=5, loop=0) self.assertNotEqual(regular, optimized)
def test_bounded_semantics_with_loop(self): # parse the ltl property spec = Node.from_ptr(parse_ltl_spec("G ( y <= 7 )")) # it must raise exception when the bound is not feasible with self.assertRaises(ValueError): ltlspec.bounded_semantics_single_loop(self.fsm, spec, -1, -2) # it must raise exception when the bound and loop are not consistent with self.assertRaises(ValueError): ltlspec.bounded_semantics_single_loop(self.fsm, spec, 5, 6) # verify that the generated problem corresponds to what is announced # without optimisation, the all loops is built as the conjunction of all # the possible 'single_loops' all_loops = ltlspec.bounded_semantics_all_loops(self.fsm, spec, 10, 0, optimized=False) acc_loops = Be.false(self.fsm.encoding.manager) for time_t in range(10): acc_loops |= ltlspec.bounded_semantics_single_loop(self.fsm, spec, 10, time_t) self.assertEqual(acc_loops, all_loops) # with optimisation, it's different all_loops = ltlspec.bounded_semantics_all_loops(self.fsm, spec, 10, 0, optimized=True) self.assertNotEqual(acc_loops, all_loops)
def test_bounded_semantics(self): # parse the ltl property spec = Node.from_ptr(parse_ltl_spec("G ( y <= 7 )")) # it must raise exception when the bound is not feasible with self.assertRaises(ValueError): ltlspec.bounded_semantics(self.fsm, spec, bound=-1) # it must raise exception when the bound and loop are not consistent with self.assertRaises(ValueError): ltlspec.bounded_semantics(self.fsm, spec, bound=5, loop=6) # verify that the generated expression corresponds to what is announced formula = ltlspec.bounded_semantics(self.fsm, spec, bound=10) no_loop = ltlspec.bounded_semantics_without_loop(self.fsm, spec, 10) all_loop = ltlspec.bounded_semantics_all_loops(self.fsm, spec, 10, 0) self.assertEqual(formula, no_loop | all_loop)
def test_bounded_semantics(self): # parse the ltl property spec = Node.from_ptr(parse_ltl_spec("G ( y <= 7 )")) # it must raise exception when the bound is not feasible with self.assertRaises(ValueError): ltlspec.bounded_semantics(self.fsm, spec, bound=-1) # it must raise exception when the bound and loop are not consistent with self.assertRaises(ValueError): ltlspec.bounded_semantics(self.fsm, spec, bound=5, loop=6) # verify that the generated expression corresponds to what is announced formula = ltlspec.bounded_semantics(self.fsm, spec, bound=10) no_loop = ltlspec.bounded_semantics_without_loop(self.fsm, spec, 10) all_loop= ltlspec.bounded_semantics_all_loops(self.fsm, spec, 10, 0) self.assertEqual(formula, no_loop | all_loop)