Esempio n. 1
0
    def test_PSOLB_paper_example(self):
        """
        Check if solution computed by PSOLB is correct on an example provided in the paper 'Fatal Attractors in Parity
        Games: Building Blocks for Partial Solvers'. Note : priorities were inversed since we work with max parity
        and the paper works with min parity.
        """
        print("test psolb paper example")
        g = io.load_from_file("examples/fatal_attractors_paper_example.txt")

        winning_region_0, winning_region_1 = zielonka.strong_parity_solver_no_strategies(
            g)
        resulting_arena, fatal_region_0, fatal_region_1 = fatal.psolB(
            g, [], [])

        expected_region_0, expected_region_1 = {2, 4, 6, 8, 0, 1, 9, 10,
                                                11}, set()
        should_remain = {3, 5, 7}

        self.assertTrue(elem in winning_region_0 for elem in fatal_region_0)
        self.assertTrue(elem in winning_region_1 for elem in fatal_region_1)

        self.assertTrue(should_remain == set(resulting_arena.get_nodes()))

        self.assertTrue(expected_region_0 == set(fatal_region_0))
        self.assertTrue(expected_region_1 == set(fatal_region_1))
Esempio n. 2
0
 def test_psolc5(self):
     print("Testing psolc algo on ltl2dba_theta")
     g = file_handler.load_from_file("examples/ltl2dba_theta.tlsf.pg")
     _, W1, _ = psolQ.psolQ(g, [], [])
     expected_W1 = set(W1)
     subg, W1, W2 = psolC.psolC(g, [], [])
     self.assertTrue(set(W1) == expected_W1)
     self.assertTrue(len(subg.get_nodes()) == 0)
Esempio n. 3
0
 def test_psolc4(self):
     print("Testing psolc algo on ltl2dba22")
     g = file_handler.load_from_file("examples/ltl2dba22.tlsf.pg")
     expected_W1 = set([])
     expected_W2 = set(range(0, 15))
     subg, W1, W2 = psolC.psolC(g, [], [])
     self.assertTrue(set(W1) == expected_W1)
     self.assertTrue(set(W2) == expected_W2)
     self.assertTrue(len(subg.get_nodes()) == 0)
Esempio n. 4
0
 def test_psolc3(self):
     print("Testing psolc algo on amba_decomposed_decode")
     g = file_handler.load_from_file(
         "examples/amba_decomposed_decode.tlsf.pg")
     expected_W1 = set([0, 3, 4, 5])
     expected_W2 = set([1, 2, 6, 7, 8, 9])
     subg, W1, W2 = psolC.psolC(g, [], [])
     self.assertTrue(set(W1) == expected_W1)
     self.assertTrue(set(W2) == expected_W2)
     self.assertTrue(len(subg.get_nodes()) == 0)
Esempio n. 5
0
 def test_jfs_algo3(self):
     print("Testing JFs algo on ltl2dba22")
     g = file_handler.load_from_file("examples/ltl2dba22.tlsf.pg")
     # winning
     expected_W = set([])
     W = psolC.jfs_algo(g, 0)
     self.assertTrue(set(W) == expected_W)
     # losing
     expected_L = set([0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 13, 14])
     L = psolC.jfs_algo(g, 1)
     self.assertTrue(set(L) == expected_L)
Esempio n. 6
0
    def test_jfs_algo2(self):
        print("Testing JFs algo on amba_decomposed_decode")
        g = file_handler.load_from_file(
            "examples/amba_decomposed_decode.tlsf.pg")
        expected_W = set([0, 3, 4, 5])
        W = psolC.jfs_algo(g, 0)
        self.assertTrue(set(W) == expected_W)

        expected_L = set([2, 6, 7, 8, 9])
        L = psolC.jfs_algo(g, 1)
        self.assertTrue(set(L) == expected_L)
Esempio n. 7
0
 def test_psolc7(self):
     print("Testing psolc algo on full_arbiter_unreal3")
     g = file_handler.load_from_file(
         "examples/full_arbiter_unreal3.tlsf.pg")
     _, W1, W2 = psolQ.psolQ(g, [], [])
     expected_W1 = set(W1)
     expected_W2 = set(W2)
     subg, W1, W2 = psolC.psolC(g, [], [])
     self.assertTrue(set(W1) == expected_W1)
     self.assertTrue(set(W2) == expected_W2)
     self.assertTrue(len(subg.get_nodes()) == 0)
        for pred in graph.get_predecessors(element[0]):

            # if said predecessors belong to player 0, compute down and add to the result
            if graph.get_node_player(pred) == 0:

                computed_down = down(element, graph.get_node_priority(pred),
                                     pred, max_counter)

                if computed_down != -1:
                    cur_antichain.insert(computed_down)

    return cur_antichain


import file_handler as io
g = io.load_from_file("parity_game_example.txt")
fixpoint = compute_fixpoint(g)
winning_region_0 = get_winning_regions(g)
print("Fixpoint : " + str(fixpoint))
print("Winning region of player 0 : " + str(winning_region_0))
"""
The rest of the file contains the same algorithm, but for player 2 (very minor changes)


def downb(element, priority, node, max_counter):
    concerned_counter = (priority // 2) + 1

    if priority % 2 == 1:

        # even priority resets the first few counters to max
        succ = [node]+max_counter[0:concerned_counter] + element[concerned_counter+1:]
Esempio n. 9
0
def ltl2dpa_pg(i):
    assert (i < len(_ltl2dpa_pgs))
    return file_handler.load_from_file("examples/" + _ltl2dpa_pgs[i])
Esempio n. 10
0
def all_examples(i):
    g = file_handler.load_from_file(os.path.join("examples", sample_files[i]))
    g.name = sample_files[i]
    return g
Esempio n. 11
0
 def specific_generator(i):
     game = file_handler.load_from_file(specific_file_name)
     game.name = specific_file_name[10:]
     return game
Esempio n. 12
0
def abo_examples(i):
    g = file_handler.load_from_file(
        os.path.join("hardexamples", abo_sample_files[i]))
    g.name = abo_sample_files[i]
    print("Experiments with " + g.name)
    return g
Esempio n. 13
0
 def test_psolc2(self):
     print("Testing psolc on ltl2dba_E.tlsf.pg")
     expected_W1 = set([])
     _, W1, W2 = psolC.psolC(
         file_handler.load_from_file("examples/ltl2dba_E.tlsf.pg"), [], [])
     self.assertTrue(set(W1) == expected_W1)