Esempio n. 1
0
    def conjunction(nodes: Set[Node], name: str = None, description: str = None) -> Node:

        try:
            new_goal = Goal.conjunction(nodes, name, description)
        except GoalException as e:
            raise CGGOperationFail(nodes=nodes, operation=CGGFailOperations.algebra_op, goal_ex=e)

        new_node = Node(goal=new_goal)

        new_node.add_children(link=Link.CONJUNCTION, nodes=nodes)

        return new_node
Esempio n. 2
0
    description="Patrolling of locations a and b, beginning from location a",
    specification=Patrolling([t["a"], t["b"]]) & Init(t["a"]))

g2 = Goal(
    name="patrol_c_d_init_c",
    description="Patrolling of locations c and d, beginning from location c",
    specification=Patrolling([t["c"], t["d"]]) & Init(t["c"]))

try:
    g12 = Goal.composition({g1, g2})
    print(g12)
except GoalException as e:
    print("Initial location is both 'a' and 'c'")

try:
    g12 = Goal.conjunction({g1, g2})
    print(g12)
except GoalException as e:
    print(
        "Conjunction has also failed since both goals have same ('TRUE') assumptions"
    )
"""We can remove the condition to begin from location c as well"""
g2 = Goal(
    name="patrol_c_d_init_c",
    description="Patrolling of locations c and d, beginning from location c",
    specification=Patrolling([t["c"], t["d"]]))

try:
    g12 = Goal.composition({g1, g2})
    print(g12)
    print("Composition Successful")