assert aut.is_deterministic() aut # Build the product. It should contain states named in the form `mdp_state,automaton_state`. p, T = lmdp.product_with_dba(aut) assert p.names == ['0,1', '1,0', '2,1', '3,1', '3,0', '0,0', '2,2'] print("Passed test 1 for product in file test_product.py") psolver = BasicES(p, 5, T) res = psolver.get_min_levels(BUCHI) assert res == [inf, inf, inf, inf, inf, inf, inf] print("Passed test 2 for product in file test_product.py") # + psolver.cap = 9 res = psolver.get_selector(BUCHI, recompute=True) result = [] for rule in res: result.append({k: v.label for k, v in rule.items()}) assert result == [{ 6: 'α', 2: 'β' }, { 3: 'r' }, { 1: 'r' }, { 0: 's' }, {
solver = BasicES(m, 15, targets) result = solver.get_min_levels(BUCHI) expected = [6, inf, inf, 3, 0, 1, 10, inf, 4, inf, inf] solver # - assert result == expected, ("get_min_levels(BUCHI) returns" + " wrong values:\n" + f" expected: {expected}\n returns: {result}\n") print("Passed test 1 for get_min_levels(BUCHI) in test_buchi file.") # ## Test case 2: insufficient capacity # The same MDP, now with capacity 14. No initial load is enough. solver.cap = 14 result = solver.get_min_levels(BUCHI, recompute=True) expected = [inf] * m.num_states solver assert result == expected, ("get_min_levels(BUCHI) returns" + " wrong values:\n" + f" expected: {expected}\n returns: {result}\n") print("Passed test 2 for get_min_levels(BUCHI) in test_buchi file.") # ## Test case 3: safe value of a reaload state is equal to capacity # There was a bug where reloads with safe_values equal to capacity were removed as unusable. m, T = little_alsure() act = m.actions_for_state(3) m.actions[act.next].distr = {0: 1}
# + m.unset_reload(11) result = MI.get_min_levels(MIN_INIT_CONS, recompute=True) expected = [0, 3, 2, 1, 3, 9, 14, 1, 1, 0, inf, inf, 1] MI # - assert result == expected, ("BasicES.get_min_levels(MIN_INIT_CONS) returns" + " wrong values:\n" + f" expected: {expected}\n returns: {result}\n") print("Passed test 2 for BasicES.get_min_levels(MIN_INIT_CONS) in test_safety file.") # ### Test BasicES with capacity MI.cap=14 result = MI.get_min_levels(MIN_INIT_CONS, recompute=True) expected = [0, 3, 2, 1, 3, 9, 14, 1, 1, 0, inf, inf, 1] MI assert result == expected, ("BasicES.get_min_levels(MIN_INIT_CONS) returns" + " wrong values:\n" + f" expected: {expected}\n returns: {result}\n") print("Passed test 3 for BasicES.get_min_levels(MIN_INIT_CONS) in test_safety file.") # Decreasing capacity should "kill" state 6 MI.cap = 13 result = MI.get_min_levels(MIN_INIT_CONS, recompute=True) expected = [0, 3, 2, 1, 3, 9, inf, 1, 1, 0, inf, inf, 1] MI