def parse_ilasp_solutions(ilasp_learnt_filename):
    with open(ilasp_learnt_filename) as f:
        automaton = SubgoalAutomaton()
        edges = {}
        for line in f:
            line = line.strip()
            if line.startswith(N_TRANSITION_STR):
                parsed_transition = parse_negative_transition_rule(line)
                current_edge = ((parsed_transition.src, parsed_transition.dst),
                                parsed_transition.edge)
                if current_edge not in edges:
                    edges[current_edge] = []
                for pos_fluent in parsed_transition.pos:
                    edges[current_edge].append("~" + pos_fluent)
                for neg_fluent in parsed_transition.neg:
                    edges[current_edge].append(neg_fluent)
            elif line.startswith(CONNECTED_STR):
                parsed_edge = parse_edge_rule(line)
                current_edge = ((parsed_edge.src, parsed_edge.dst),
                                parsed_edge.edge)
                if current_edge not in edges:
                    edges[current_edge] = []

        for edge in edges:
            from_state, to_state = edge[0]
            automaton.add_state(from_state)
            automaton.add_state(to_state)
            automaton.add_edge(from_state, to_state, edges[edge])

        return automaton
 def get_automaton(self):
     automaton = SubgoalAutomaton()
     automaton.add_state("u0")
     automaton.add_state("u1")
     automaton.add_state("u_acc")
     automaton.add_state("u_rej")
     automaton.add_edge("u0", "u1", [
         OfficeWorldObject.MAIL, "~" + OfficeWorldObject.OFFICE,
         "~" + OfficeWorldObject.PLANT
     ])
     automaton.add_edge("u0", "u_acc", [
         OfficeWorldObject.MAIL, OfficeWorldObject.OFFICE,
         "~" + OfficeWorldObject.PLANT
     ])
     automaton.add_edge("u0", "u_rej", [OfficeWorldObject.PLANT])
     automaton.add_edge(
         "u1", "u_acc",
         [OfficeWorldObject.OFFICE, "~" + OfficeWorldObject.PLANT])
     automaton.add_edge("u1", "u_rej", [OfficeWorldObject.PLANT])
     automaton.set_initial_state("u0")
     automaton.set_accept_state("u_acc")
     automaton.set_reject_state("u_rej")
     return automaton
    def get_automaton(self):
        automaton = SubgoalAutomaton()
        automaton.add_state("u0")
        automaton.add_state("u1")
        automaton.add_state("u_acc")

        if self.enforce_single_observable_per_location:
            automaton.add_edge("u0", "u1", [CraftWorldObject.GRASS])
        else:
            automaton.add_edge(
                "u0", "u1",
                [CraftWorldObject.GRASS, "~" + CraftWorldObject.TOOLSHED])
            automaton.add_edge(
                "u0", "u_acc",
                [CraftWorldObject.GRASS, CraftWorldObject.TOOLSHED])
        automaton.add_edge("u1", "u_acc", [CraftWorldObject.TOOLSHED])

        automaton.set_initial_state("u0")
        automaton.set_accept_state("u_acc")
        return automaton
 def get_automaton(self):
     automaton = SubgoalAutomaton()
     automaton.add_state("u0")
     automaton.add_state("u1")
     automaton.add_state("u2")
     automaton.add_state("u3")
     automaton.add_state("u_acc")
     automaton.add_state("u_rej")
     automaton.add_edge(
         "u0", "u1",
         [OfficeWorldObject.ROOM_A, "~" + OfficeWorldObject.PLANT])
     automaton.add_edge("u0", "u_rej", [OfficeWorldObject.PLANT])
     automaton.add_edge(
         "u1", "u2",
         [OfficeWorldObject.ROOM_B, "~" + OfficeWorldObject.PLANT])
     automaton.add_edge("u1", "u_rej", [OfficeWorldObject.PLANT])
     automaton.add_edge(
         "u2", "u3",
         [OfficeWorldObject.ROOM_C, "~" + OfficeWorldObject.PLANT])
     automaton.add_edge("u2", "u_rej", [OfficeWorldObject.PLANT])
     automaton.add_edge(
         "u3", "u_acc",
         [OfficeWorldObject.ROOM_D, "~" + OfficeWorldObject.PLANT])
     automaton.add_edge("u3", "u_rej", [OfficeWorldObject.PLANT])
     automaton.set_initial_state("u0")
     automaton.set_accept_state("u_acc")
     automaton.set_reject_state("u_rej")
     return automaton
    def get_automaton(self):
        automaton = SubgoalAutomaton()
        automaton.add_state("u0")
        automaton.add_state("u1")
        automaton.add_state("u_acc")

        automaton.add_edge(
            "u0", "u_acc",
            [OfficeWorldObject.COFFEE, OfficeWorldObject.OFFICE])
        automaton.add_edge("u0", "u_acc",
                           [OfficeWorldObject.MAIL, OfficeWorldObject.OFFICE])
        automaton.add_edge(
            "u1", "u_acc",
            [OfficeWorldObject.OFFICE, "~" + OfficeWorldObject.PLANT])

        if self.drop_coffee_on_plant_enable:
            automaton.add_state("u2")
            automaton.add_edge(
                "u0", "u1",
                [OfficeWorldObject.COFFEE, "~" + OfficeWorldObject.OFFICE])
            automaton.add_edge(
                "u0", "u2",
                [OfficeWorldObject.MAIL, "~" + OfficeWorldObject.OFFICE])
            automaton.add_edge("u1", "u0", [OfficeWorldObject.PLANT])
            automaton.add_edge("u2", "u_acc", [OfficeWorldObject.OFFICE])
        else:
            automaton.add_state("u_rej")
            automaton.set_reject_state("u_rej")
            automaton.add_edge(
                "u0", "u1",
                [OfficeWorldObject.COFFEE, "~" + OfficeWorldObject.OFFICE])
            automaton.add_edge(
                "u0", "u1",
                [OfficeWorldObject.MAIL, "~" + OfficeWorldObject.OFFICE])
            automaton.add_edge("u0", "u_rej", [
                OfficeWorldObject.PLANT, "~" + OfficeWorldObject.COFFEE,
                "~" + OfficeWorldObject.MAIL
            ])
            automaton.add_edge("u1", "u_rej", [OfficeWorldObject.PLANT])

        automaton.set_initial_state("u0")
        automaton.set_accept_state("u_acc")
        return automaton
    def get_automaton(self):
        automaton = SubgoalAutomaton()
        automaton.add_state("u0")
        automaton.add_state("u1")
        automaton.add_state("u2")
        automaton.add_state("u3")
        automaton.add_state("u4")
        automaton.add_state("u5")
        automaton.add_state("u6")
        automaton.add_state("u_acc")

        if self.enforce_single_observable_per_location:
            automaton.add_edge(
                "u0", "u1",
                [CraftWorldObject.WOOD, "~" + CraftWorldObject.IRON])
            automaton.add_edge("u0", "u4", [CraftWorldObject.IRON])
            automaton.add_edge(
                "u1", "u3",
                [CraftWorldObject.WORKBENCH, "~" + CraftWorldObject.IRON])
            automaton.add_edge("u1", "u5", [CraftWorldObject.IRON])
            automaton.add_edge("u3", "u6", [CraftWorldObject.IRON])
            automaton.add_edge("u4", "u5", [CraftWorldObject.WOOD])
            automaton.add_edge("u5", "u6", [CraftWorldObject.WORKBENCH])
            automaton.add_edge("u6", "u2", [CraftWorldObject.TOOLSHED])
        else:
            automaton.add_edge("u0", "u1", [
                CraftWorldObject.WOOD, "~" + CraftWorldObject.WORKBENCH,
                "~" + CraftWorldObject.IRON
            ])
            automaton.add_edge("u0", "u2", [
                CraftWorldObject.WOOD, CraftWorldObject.TOOLSHED,
                CraftWorldObject.WORKBENCH, CraftWorldObject.IRON,
                "~" + CraftWorldObject.AXE
            ])
            automaton.add_edge("u0", "u3", [
                CraftWorldObject.WOOD, CraftWorldObject.WORKBENCH,
                "~" + CraftWorldObject.IRON
            ])
            automaton.add_edge(
                "u0", "u4",
                ["~" + CraftWorldObject.WOOD, CraftWorldObject.IRON])
            automaton.add_edge("u0", "u5", [
                CraftWorldObject.WOOD, "~" + CraftWorldObject.WORKBENCH,
                CraftWorldObject.IRON
            ])
            automaton.add_edge("u0", "u6", [
                CraftWorldObject.WOOD, "~" + CraftWorldObject.TOOLSHED,
                CraftWorldObject.WORKBENCH, CraftWorldObject.IRON
            ])
            automaton.add_edge("u0", "u_acc", [
                CraftWorldObject.WOOD, CraftWorldObject.TOOLSHED,
                CraftWorldObject.WORKBENCH, CraftWorldObject.IRON,
                CraftWorldObject.AXE
            ])
            automaton.add_edge("u1", "u2", [
                CraftWorldObject.TOOLSHED, CraftWorldObject.WORKBENCH,
                CraftWorldObject.IRON, "~" + CraftWorldObject.AXE
            ])
            automaton.add_edge(
                "u1", "u3",
                [CraftWorldObject.WORKBENCH, "~" + CraftWorldObject.IRON])
            automaton.add_edge(
                "u1", "u5",
                ["~" + CraftWorldObject.WORKBENCH, CraftWorldObject.IRON])
            automaton.add_edge("u1", "u6", [
                "~" + CraftWorldObject.TOOLSHED, CraftWorldObject.WORKBENCH,
                CraftWorldObject.IRON
            ])
            automaton.add_edge("u1", "u_acc", [
                CraftWorldObject.TOOLSHED, CraftWorldObject.WORKBENCH,
                CraftWorldObject.IRON, CraftWorldObject.AXE
            ])
            automaton.add_edge("u3", "u2", [
                CraftWorldObject.TOOLSHED, CraftWorldObject.IRON,
                "~" + CraftWorldObject.AXE
            ])
            automaton.add_edge(
                "u3", "u6",
                ["~" + CraftWorldObject.TOOLSHED, CraftWorldObject.IRON])
            automaton.add_edge("u3", "u_acc", [
                CraftWorldObject.TOOLSHED, CraftWorldObject.IRON,
                CraftWorldObject.AXE
            ])
            automaton.add_edge("u4", "u2", [
                CraftWorldObject.WOOD, CraftWorldObject.TOOLSHED,
                CraftWorldObject.WORKBENCH, "~" + CraftWorldObject.AXE
            ])
            automaton.add_edge(
                "u4", "u5",
                [CraftWorldObject.WOOD, "~" + CraftWorldObject.WORKBENCH])
            automaton.add_edge("u4", "u6", [
                CraftWorldObject.WOOD, "~" + CraftWorldObject.TOOLSHED,
                CraftWorldObject.WORKBENCH
            ])
            automaton.add_edge("u4", "u_acc", [
                CraftWorldObject.WOOD, CraftWorldObject.TOOLSHED,
                CraftWorldObject.WORKBENCH, CraftWorldObject.AXE
            ])
            automaton.add_edge("u5", "u2", [
                CraftWorldObject.TOOLSHED, CraftWorldObject.WORKBENCH,
                "~" + CraftWorldObject.AXE
            ])
            automaton.add_edge(
                "u5", "u6",
                ["~" + CraftWorldObject.TOOLSHED, CraftWorldObject.WORKBENCH])
            automaton.add_edge("u5", "u_acc", [
                CraftWorldObject.TOOLSHED, CraftWorldObject.WORKBENCH,
                CraftWorldObject.AXE
            ])
            automaton.add_edge(
                "u6", "u2",
                [CraftWorldObject.TOOLSHED, "~" + CraftWorldObject.AXE])
            automaton.add_edge(
                "u6", "u_acc",
                [CraftWorldObject.TOOLSHED, CraftWorldObject.AXE])
        automaton.add_edge("u2", "u_acc", [CraftWorldObject.AXE])

        automaton.set_initial_state("u0")
        automaton.set_accept_state("u_acc")
        return automaton
    def get_automaton(self):
        automaton = SubgoalAutomaton()
        automaton.add_state("u0")
        automaton.add_state("u1")
        automaton.add_state("u2")
        automaton.add_state("u3")
        automaton.add_state("u4")
        automaton.add_state("u_acc")

        if self.enforce_single_observable_per_location:
            automaton.add_edge(
                "u0", "u2",
                ["~" + CraftWorldObject.WOOD, CraftWorldObject.IRON])
            automaton.add_edge("u0", "u3", [CraftWorldObject.WOOD])
            automaton.add_edge("u2", "u4", [CraftWorldObject.WOOD])
            automaton.add_edge("u3", "u4", [CraftWorldObject.IRON])
            automaton.add_edge("u4", "u1", [CraftWorldObject.FACTORY])
        else:
            automaton.add_edge("u0", "u1", [
                CraftWorldObject.WOOD, CraftWorldObject.FACTORY,
                CraftWorldObject.IRON, "~" + CraftWorldObject.BRIDGE
            ])
            automaton.add_edge(
                "u0", "u2",
                ["~" + CraftWorldObject.WOOD, CraftWorldObject.IRON])
            automaton.add_edge(
                "u0", "u3",
                [CraftWorldObject.WOOD, "~" + CraftWorldObject.IRON])
            automaton.add_edge("u0", "u4", [
                CraftWorldObject.WOOD, "~" + CraftWorldObject.FACTORY,
                CraftWorldObject.IRON
            ])
            automaton.add_edge("u0", "u_acc", [
                CraftWorldObject.WOOD, CraftWorldObject.FACTORY,
                CraftWorldObject.IRON, CraftWorldObject.BRIDGE
            ])
            automaton.add_edge("u2", "u1", [
                CraftWorldObject.WOOD, CraftWorldObject.FACTORY,
                "~" + CraftWorldObject.BRIDGE
            ])
            automaton.add_edge(
                "u2", "u4",
                [CraftWorldObject.WOOD, "~" + CraftWorldObject.FACTORY])
            automaton.add_edge("u2", "u_acc", [
                CraftWorldObject.WOOD, CraftWorldObject.FACTORY,
                CraftWorldObject.BRIDGE
            ])
            automaton.add_edge("u3", "u1", [
                CraftWorldObject.FACTORY, CraftWorldObject.IRON,
                "~" + CraftWorldObject.BRIDGE
            ])
            automaton.add_edge(
                "u3", "u4",
                ["~" + CraftWorldObject.FACTORY, CraftWorldObject.IRON])
            automaton.add_edge("u3", "u_acc", [
                CraftWorldObject.FACTORY, CraftWorldObject.IRON,
                CraftWorldObject.BRIDGE
            ])
            automaton.add_edge(
                "u4", "u1",
                [CraftWorldObject.FACTORY, "~" + CraftWorldObject.BRIDGE])
            automaton.add_edge(
                "u4", "u_acc",
                [CraftWorldObject.FACTORY, CraftWorldObject.BRIDGE])
        automaton.add_edge("u1", "u_acc", [CraftWorldObject.BRIDGE])

        automaton.set_initial_state("u0")
        automaton.set_accept_state("u_acc")
        return automaton