Exemplo n.º 1
0
class PlanGraphLevel(object):
    """
    A class for representing a level in the plan graph.
    For each level i, the PlanGraphLevel consists of the actionLayer and propositionLayer at this level in this order!
    """
    independent_actions = set(
    )  # updated to the independent_actions of the problem (graph_plan.py line 32)
    actions = [
    ]  # updated to the actions of the problem (graph_plan.py line 33 and planning_problem.py line 36)
    props = [
    ]  # updated to the propositions of the problem (graph_plan.py line 34 and planning_problem.py line 36)

    @staticmethod
    def set_independent_actions(independent_actions):
        PlanGraphLevel.independent_actions = independent_actions

    @staticmethod
    def set_actions(actions):
        PlanGraphLevel.actions = actions

    @staticmethod
    def set_props(props):
        PlanGraphLevel.props = props

    def __init__(self):
        """
        Constructor
        """
        self.action_layer = ActionLayer()  # see action_layer.py
        self.proposition_layer = PropositionLayer()  # see proposition_layer.py

    def get_proposition_layer(self):  # returns the proposition layer
        return self.proposition_layer

    def set_proposition_layer(self, prop_layer):  # sets the proposition layer
        self.proposition_layer = prop_layer

    def get_action_layer(self):  # returns the action layer
        return self.action_layer

    def set_action_layer(self, action_layer):  # sets the action layer
        self.action_layer = action_layer

    def update_action_layer(self,
                            previous_proposition_layer: PropositionLayer):
        """
        Updates the action layer given the previous proposition layer (see proposition_layer.py)
        You should add an action to the layer if its preconditions are in the previous propositions layer,
        and the preconditions are not pairwise mutex.
        all_actions is the set of all the action (include noOp) in the domain
        You might want to use those functions:
        previous_proposition_layer.is_mutex(prop1, prop2) returns true
        if prop1 and prop2 are mutex at the previous propositions layer
        previous_proposition_layer.all_preconds_in_layer(action) returns true
        if all the preconditions of action are in the previous propositions layer
        self.actionLayer.addAction(action) adds action to the current action layer
        """
        all_actions = PlanGraphLevel.actions
        for action in all_actions:
            if all_preconditions_are_met(action, previous_proposition_layer) \
                    and preconditions_are_not_mutex(action, previous_proposition_layer):
                self.action_layer.add_action(action)

    def update_mutex_actions(self, previous_layer_mutex_proposition):
        """
        Updates the mutex set in self.action_layer,
        given the mutex proposition from the previous layer.
        current_layer_actions are the actions in the current action layer
        You might want to use this function:
        self.actionLayer.add_mutex_actions(action1, action2)
        adds the pair (action1, action2) to the mutex set in the current action layer
        Note that an action is *not* mutex with itself
        """
        current_layer_actions = self.action_layer.get_actions()
        list_of_current_actions = list(current_layer_actions)
        for i, curr_action in enumerate(list_of_current_actions):
            for other_action in list_of_current_actions[i + 1:]:
                if competing_needs_exists(curr_action, other_action):
                    self.action_layer.add_mutex_actions(
                        curr_action, other_action)
                    continue
                check_if_pre_conditions_are_mutex(
                    curr_action, other_action,
                    previous_layer_mutex_proposition, self)

    def update_proposition_layer(self):
        """
        Updates the propositions in the current proposition layer,
        given the current action layer.
        don't forget to update the producers list!
        Note that same proposition in different layers might have different producers lists,
        hence you should create two different instances.
        current_layer_actions is the set of all the actions in the current layer.
        You might want to use those functions:
        dict() creates a new dictionary that might help to keep track on the propositions that you've
               already added to the layer
        self.proposition_layer.add_proposition(prop) adds the proposition prop to the current layer

        """
        current_layer_actions = self.action_layer.get_actions()
        proposition_layer = self.get_proposition_layer()
        previous_layer_propositions = proposition_layer.get_propositions()
        new_propositions = {
            prop.name: Proposition(prop.name)
            for prop in previous_layer_propositions
        }
        for action in current_layer_actions:
            for proposition_to_add in action.get_add():
                add_proposition_to_next_layer(action, new_propositions,
                                              proposition_layer,
                                              proposition_to_add)

    def update_mutex_proposition(self):
        """
        updates the mutex propositions in the current proposition layer
        You might want to use those functions:
        mutex_propositions(prop1, prop2, current_layer_mutex_actions) returns true
        if prop1 and prop2 are mutex in the current layer
        self.proposition_layer.add_mutex_prop(prop1, prop2) adds the pair (prop1, prop2)
        to the mutex set of the current layer
        """
        current_layer_propositions = list(
            self.proposition_layer.get_propositions())
        current_layer_mutex_actions = self.action_layer.get_mutex_actions()
        for ind, proposition_1 in enumerate(current_layer_propositions):
            for proposition_2 in current_layer_propositions[ind + 1:]:
                if mutex_propositions(proposition_1, proposition_2,
                                      current_layer_mutex_actions):
                    self.proposition_layer.add_mutex_prop(
                        proposition_1, proposition_2)

    def expand(self, previous_layer):
        """
        Your algorithm should work as follows:
        First, given the propositions and the list of mutex propositions from the previous layer,
        set the actions in the action layer.
        Then, set the mutex action in the action layer.
        Finally, given all the actions in the current layer,
        set the propositions and their mutex relations in the proposition layer.
        """
        previous_proposition_layer = previous_layer.get_proposition_layer()
        previous_layer_mutex_proposition = previous_proposition_layer.get_mutex_props(
        )
        self.update_action_layer(previous_proposition_layer)
        self.update_mutex_actions(previous_layer_mutex_proposition)
        self.update_proposition_layer()
        self.update_mutex_proposition()

    def expand_without_mutex(self, previous_layer):
        """
        Questions 11 and 12
        You don't have to use this function
        """
        previous_layer_proposition = previous_layer.get_proposition_layer()
        "*** YOUR CODE HERE ***"
        self.update_action_layer(previous_layer_proposition)
        self.update_proposition_layer()
class PlanGraphLevel(object):
    """
    A class for representing a level in the plan graph.
    For each level i, the PlanGraphLevel consists of the actionLayer and propositionLayer at this level in this order!
    """
    independent_actions = set(
    )  # updated to the independent_actions of the problem (graph_plan.py line 32)
    actions = [
    ]  # updated to the actions of the problem (graph_plan.py line 33 and planning_problem.py line 36)
    props = [
    ]  # updated to the propositions of the problem (graph_plan.py line 34 and planning_problem.py line 36)

    @staticmethod
    def set_independent_actions(independent_actions):
        PlanGraphLevel.independent_actions = independent_actions

    @staticmethod
    def set_actions(actions):
        PlanGraphLevel.actions = actions

    @staticmethod
    def set_props(props):
        PlanGraphLevel.props = props

    def __init__(self):
        """
        Constructor
        """
        self.action_layer = ActionLayer()  # see action_layer.py
        self.proposition_layer = PropositionLayer()  # see proposition_layer.py

    def get_proposition_layer(self):  # returns the proposition layer
        return self.proposition_layer

    def set_proposition_layer(self, prop_layer):  # sets the proposition layer
        self.proposition_layer = prop_layer

    def get_action_layer(self):  # returns the action layer
        return self.action_layer

    def set_action_layer(self, action_layer):  # sets the action layer
        self.action_layer = action_layer

    def update_action_layer(self, previous_proposition_layer):
        """
        Updates the action layer given the previous proposition layer (see proposition_layer.py)
        You should add an action to the layer if its preconditions are in the previous propositions layer,
        and the preconditions are not pairwise mutex.
        all_actions is the set of all the action (include noOp) in the domain
        You might want to use those functions:
        previous_proposition_layer.is_mutex(prop1, prop2) returns true
        if prop1 and prop2 are mutex at the previous propositions layer
        previous_proposition_layer.all_preconds_in_layer(action) returns true
        if all the preconditions of action are in the previous propositions layer
        self.actionLayer.addAction(action) adds action to the current action layer
        """
        all_actions = PlanGraphLevel.actions
        for action in all_actions:
            if previous_proposition_layer.all_preconds_in_layer(action):
                pre = action.get_pre()
                to_add = False
                for prop1 in pre:
                    for prop2 in pre:
                        if prop1 != prop2 and previous_proposition_layer.is_mutex(
                                prop1, prop2):
                            to_add = True
                if not to_add:
                    self.action_layer.add_action(action)

    def update_mutex_actions(self, previous_layer_mutex_proposition):
        """
        Updates the mutex set in self.action_layer,
        given the mutex proposition from the previous layer.
        current_layer_actions are the actions in the current action layer
        You might want to use this function:
        self.actionLayer.add_mutex_actions(action1, action2)
        adds the pair (action1, action2) to the mutex set in the current action layer
        Note that an action is *not* mutex with itself
        """
        current_layer_actions = self.action_layer.get_actions()
        for i in current_layer_actions:
            for j in current_layer_actions:
                if i != j and mutex_actions(i, j,
                                            previous_layer_mutex_proposition):
                    self.action_layer.add_mutex_actions(i, j)

    def update_proposition_layer(self):
        """
        Updates the propositions in the current proposition layer,
        given the current action layer.
        don't forget to update the producers list!
        Note that same proposition in different layers might have different producers lists,
        hence you should create two different instances.
        current_layer_actions is the set of all the actions in the current layer.
        You might want to use those functions:
        dict() creates a new dictionary that might help to keep track on the propositions that you've
               already added to the layer
        self.proposition_layer.add_proposition(prop) adds the proposition prop to the current layer
        """
        current_layer_actions = self.action_layer.get_actions()
        prop_dict = dict()
        for act in current_layer_actions:
            add_prop_list = act.get_add()
            for prop in add_prop_list:
                if prop not in prop_dict:
                    prop_dict[prop] = [act]
                else:
                    prop_dict[prop].append(act)
        for prop, act_list in prop_dict.items():
            prop.set_producers(act_list)
            self.proposition_layer.add_proposition(prop)

    def update_mutex_proposition(self):
        """
        updates the mutex propositions in the current proposition layer
        You might want to use those functions:
        mutex_propositions(prop1, prop2, current_layer_mutex_actions) returns true
        if prop1 and prop2 are mutex in the current layer
        self.proposition_layer.add_mutex_prop(prop1, prop2) adds the pair (prop1, prop2)
        to the mutex set of the current layer
        """
        current_layer_propositions = self.proposition_layer.get_propositions()
        current_layer_mutex_actions = self.action_layer.get_mutex_actions()
        for i in current_layer_propositions:
            for j in current_layer_propositions:
                if i != j and mutex_propositions(i, j,
                                                 current_layer_mutex_actions):
                    self.proposition_layer.add_mutex_prop(i, j)

    def expand(self, previous_layer):
        """
        Your algorithm should work as follows:
        First, given the propositions and the list of mutex propositions from the previous layer,
        set the actions in the action layer.
        Then, set the mutex action in the action layer.
        Finally, given all the actions in the current layer,
        set the propositions and their mutex relations in the proposition layer.
        """
        previous_proposition_layer = previous_layer.get_proposition_layer()
        previous_layer_mutex_proposition = previous_proposition_layer.get_mutex_props(
        )
        self.update_action_layer(previous_proposition_layer)
        self.update_mutex_actions(previous_layer_mutex_proposition)
        self.update_proposition_layer()
        self.update_mutex_proposition()

    def expand_without_mutex(self, previous_layer):
        """
        Questions 11 and 12
        You don't have to use this function
        """
        previous_layer_proposition = previous_layer.get_proposition_layer()
        self.update_action_layer(previous_layer_proposition)
        self.update_proposition_layer()
Exemplo n.º 3
0
class PlanGraphLevel(object):
    """
    A class for representing a level in the plan graph.
    For each level i, the PlanGraphLevel consists of the actionLayer and propositionLayer at this level in this order!
    """
    independent_actions = set(
    )  # updated to the independent_actions of the problem (graph_plan.py line 32)
    actions = [
    ]  # updated to the actions of the problem (graph_plan.py line 33 and planning_problem.py line 36)
    props = [
    ]  # updated to the propositions of the problem (graph_plan.py line 34 and planning_problem.py line 36)

    @staticmethod
    def set_independent_actions(independent_actions):
        PlanGraphLevel.independent_actions = independent_actions

    @staticmethod
    def set_actions(actions):
        PlanGraphLevel.actions = actions

    @staticmethod
    def set_props(props):
        PlanGraphLevel.props = props

    def __init__(self):
        """
        Constructor
        """
        self.action_layer = ActionLayer()  # see action_layer.py
        self.proposition_layer = PropositionLayer()  # see proposition_layer.py

    def get_proposition_layer(self):  # returns the proposition layer
        return self.proposition_layer

    def set_proposition_layer(self, prop_layer):  # sets the proposition layer
        self.proposition_layer = prop_layer

    def get_action_layer(self):  # returns the action layer
        return self.action_layer

    def set_action_layer(self, action_layer):  # sets the action layer
        self.action_layer = action_layer

    def update_action_layer(self, previous_proposition_layer):
        """
        Updates the action layer given the previous proposition layer (see proposition_layer.py)
        You should add an action to the layer if its preconditions are in the previous propositions layer,
        and the preconditions are not pairwise mutex.
        all_actions is the set of all the action (include noOp) in the domain
        You might want to use those functions:
        previous_proposition_layer.is_mutex(prop1, prop2) returns true
        if prop1 and prop2 are mutex at the previous propositions layer
        previous_proposition_layer.all_preconds_in_layer(action) returns true
        if all the preconditions of action are in the previous propositions layer
        self.actionLayer.addAction(action) adds action to the current action layer
        """
        all_actions = PlanGraphLevel.actions
        "*** YOUR CODE HERE ***"
        for action in all_actions:
            if not previous_proposition_layer.all_preconds_in_layer(action):
                continue
            else:
                all_combinations = [
                    previous_proposition_layer.is_mutex(cond1, cond2)
                    for cond1 in action.get_pre()
                    for cond2 in action.get_pre() if cond1 != cond2
                ]
                if not any(all_combinations):
                    self.action_layer.add_action(action)

    def update_mutex_actions(self, previous_layer_mutex_proposition):
        """
        Updates the mutex set in self.action_layer,
        given the mutex proposition from the previous layer.
        current_layer_actions are the actions in the current action layer
        You might want to use this function:
        self.actionLayer.add_mutex_actions(action1, action2)
        adds the pair (action1, action2) to the mutex set in the current action layer
        Note that an action is *not* mutex with itself
        """
        current_layer_actions = self.action_layer.get_actions()
        "*** YOUR CODE HERE ***"
        all_combinations = [(action1, action2)
                            for action1 in current_layer_actions
                            for action2 in current_layer_actions
                            if action1 != action2]
        for combination in all_combinations:
            if mutex_actions(combination[0], combination[1],
                             previous_layer_mutex_proposition):
                if Pair(combination[0], combination[1]
                        ) not in self.action_layer.get_mutex_actions():
                    self.action_layer.add_mutex_actions(
                        combination[0], combination[1])

    def update_proposition_layer(self):
        """
        Updates the propositions in the current proposition layer,
        given the current action layer.
        don't forget to update the producers list!
        Note that same proposition in different layers might have different producers lists,
        hence you should create two different instances.
        current_layer_actions is the set of all the actions in the current layer.
        You might want to use those functions:
        dict() creates a new dictionary that might help to keep track on the propositions that you've
               already added to the layer
        self.proposition_layer.add_proposition(prop) adds the proposition prop to the current layer

        """
        dic = dict()
        current_layer_actions = self.action_layer.get_actions()
        "*** YOUR CODE HERE ***"
        for action in current_layer_actions:
            for proposition in action.get_add():
                if proposition.get_name() not in dic.values():
                    new_prop = Proposition(proposition.get_name())
                    self.proposition_layer.add_proposition(new_prop)
                    dic[new_prop] = new_prop.get_name()
                keys = list(dic.keys())
                values = list(dic.values())
                new_prop = keys[values.index(proposition.name)]
                new_prop.add_producer(action)

    def update_mutex_proposition(self):
        """
        updates the mutex propositions in the current proposition layer
        You might want to use those functions:
        mutex_propositions(prop1, prop2, current_layer_mutex_actions) returns true
        if prop1 and prop2 are mutex in the current layer
        self.proposition_layer.add_mutex_prop(prop1, prop2) adds the pair (prop1, prop2)
        to the mutex set of the current layer
        """
        current_layer_propositions = self.proposition_layer.get_propositions()
        current_layer_mutex_actions = self.action_layer.get_mutex_actions()
        "*** YOUR CODE HERE ***"
        combinations = [(proposition1, proposition2)
                        for proposition1 in current_layer_propositions
                        for proposition2 in current_layer_propositions
                        if proposition1 != proposition2]
        for pair in combinations:
            if mutex_propositions(pair[0], pair[1], current_layer_mutex_actions) and \
                    Pair(pair[0], pair[1]) not in self.proposition_layer.get_mutex_props():
                self.proposition_layer.add_mutex_prop(pair[0], pair[1])

    def expand(self, previous_layer):
        """
        Your algorithm should work as follows:
        First, given the propositions and the list of mutex propositions from the previous layer,
        set the actions in the action layer.
        Then, set the mutex action in the action layer.
        Finally, given all the actions in the current layer,
        set the propositions and their mutex relations in the proposition layer.
        """
        previous_proposition_layer = previous_layer.get_proposition_layer()
        previous_layer_mutex_proposition = previous_proposition_layer.get_mutex_props(
        )
        "*** YOUR CODE HERE ***"
        self.update_action_layer(previous_proposition_layer)
        self.update_mutex_actions(previous_layer_mutex_proposition)
        self.update_proposition_layer()
        self.update_mutex_proposition()
        # print("actions")
        # for action in self.action_layer.get_actions():
        #     print(action, end = " ")
        # print("mutex_action")
        # for mutex_action in self.action_layer.get_mutex_actions():
        #    print(mutex_action, end = " ")
        # print("props")
        # for prop in self.proposition_layer.get_propositions():
        #    print(prop, end = " ")
        # print("mutex_props")
        # for mutex_prop in self.proposition_layer.get_mutex_props():
        #    print(mutex_prop, end = " ")
        # print("end")

    def expand_without_mutex(self, previous_layer):
        """
        Questions 11 and 12
        You don't have to use this function
        """
        previous_layer_proposition = previous_layer.get_proposition_layer()
        "*** YOUR CODE HERE ***"
        self.update_action_layer(previous_layer_proposition)
        self.update_proposition_layer()
class PlanGraphLevel(object):
    """
    A class for representing a level in the plan graph.
    For each level i, the PlanGraphLevel consists of the actionLayer and propositionLayer at this level in this order!
    """
    independent_actions = set()  # updated to the independent_actions of the problem (graph_plan.py line 32)
    actions = []  # updated to the actions of the problem (graph_plan.py line 33 and planning_problem.py line 36)
    props = []  # updated to the propositions of the problem (graph_plan.py line 34 and planning_problem.py line 36)

    @staticmethod
    def set_independent_actions(independent_actions):
        PlanGraphLevel.independent_actions = independent_actions

    @staticmethod
    def set_actions(actions):
        PlanGraphLevel.actions = actions

    @staticmethod
    def set_props(props):
        PlanGraphLevel.props = props

    def __init__(self):
        """
        Constructor
        """
        self.action_layer = ActionLayer()  # see action_layer.py
        self.proposition_layer = PropositionLayer()  # see proposition_layer.py

    def get_proposition_layer(self):  # returns the proposition layer
        return self.proposition_layer

    def set_proposition_layer(self, prop_layer):  # sets the proposition layer
        self.proposition_layer = prop_layer

    def get_action_layer(self):  # returns the action layer
        return self.action_layer

    def set_action_layer(self, action_layer):  # sets the action layer
        self.action_layer = action_layer

    def update_action_layer(self, previous_proposition_layer):
        """
        Updates the action layer given the previous proposition layer (see proposition_layer.py)
        You should add an action to the layer if its preconditions are in the previous propositions layer,
        and the preconditions are not pairwise mutex.
        all_actions is the set of all the action (include noOp) in the domain
        You might want to use those functions:
        previous_proposition_layer.is_mutex(prop1, prop2) returns true
        if prop1 and prop2 are mutex at the previous propositions layer
        previous_proposition_layer.all_preconds_in_layer(action) returns true
        if all the preconditions of action are in the previous propositions layer
        self.actionLayer.addAction(action) adds action to the current action layer
        """
        all_actions = PlanGraphLevel.actions
        for action in all_actions:
            if not previous_proposition_layer.all_preconds_in_layer(action):
                continue
            action_props_list = action.get_pre()
            mutex_flag = False
            for i in range(len(action_props_list) - 1):
                mutex_flag2 = False
                for j in range(i +1, len(action_props_list)):
                    if previous_proposition_layer.is_mutex(
                            action_props_list[i], action_props_list[j]):
                        mutex_flag = True
                        break
                if mutex_flag:
                    break
            if mutex_flag:
                continue
            else:
                self.action_layer.add_action(action)


    def update_mutex_actions(self, previous_layer_mutex_proposition):
        """
        Updates the mutex set in self.action_layer,
        given the mutex proposition from the previous layer.
        current_layer_actions are the actions in the current action layer
        You might want to use this function:
        self.actionLayer.add_mutex_actions(action1, action2)
        adds the pair (action1, action2) to the mutex set in the current action layer
        Note that an action is *not* mutex with itself
        """
        current_layer_actions = list(self.action_layer.get_actions())
        for action1 in current_layer_actions:
            for action2 in current_layer_actions:
                if action1 != action2 and mutex_actions(action1, action2,
                                 previous_layer_mutex_proposition):
                    self.action_layer.add_mutex_actions(action1, action2)

    def update_proposition_layer(self):
        """
        Updates the propositions in the current proposition layer,
        given the current action layer.
        don't forget to update the producers list!
        Note that same proposition in different layers might have different producers lists,
        hence you should create two different instances.
        current_layer_actions is the set of all the actions in the current layer.
        You might want to use those functions:
        dict() creates a new dictionary that might help to keep track on the propositions that you've
               already added to the layer
        self.proposition_layer.add_proposition(prop) adds the proposition prop to the current layer

        """
        current_layer_actions = self.action_layer.get_actions()
        new_props_set = set()
        for action1 in current_layer_actions:
            list_of_propo = action1.get_add()
            for propo in list_of_propo:
                new_props_set.add(propo.name)
        props_dict = dict.fromkeys(new_props_set, set())
        for action2 in current_layer_actions:
            list_of_propo2 = action2.get_add()
            for propo2 in list_of_propo2:
                props_dict[propo2.get_name()].add(action2)
        for prop in props_dict:
            my_prop = Proposition(prop)
            my_prop.set_producers(list(props_dict[prop]))
            self.proposition_layer.add_proposition(my_prop)


    def update_mutex_proposition(self):
        """
        updates the mutex propositions in the current proposition layer
        You might want to use those functions:
        mutex_propositions(prop1, prop2, current_layer_mutex_actions) returns true
        if prop1 and prop2 are mutex in the current layer
        self.proposition_layer.add_mutex_prop(prop1, prop2) adds the pair (prop1, prop2)
        to the mutex set of the current layer
        """
        current_layer_propositions = \
            list(self.proposition_layer.get_propositions())
        current_layer_mutex_actions = self.action_layer.get_mutex_actions()
        for prop1 in current_layer_propositions:
            for prop2 in current_layer_propositions:
                if prop1 != prop2 and mutex_propositions(prop1, prop2,
                                      current_layer_mutex_actions):
                    self.proposition_layer.add_mutex_prop(prop1, prop2)

    def expand(self, previous_layer):
        """
        Your algorithm should work as follows:
        First, given the propositions and the list of mutex propositions from the previous layer,
        set the actions in the action layer.
        Then, set the mutex action in the action layer.
        Finally, given all the actions in the current layer,
        set the propositions and their mutex relations in the proposition layer.
        """
        previous_proposition_layer = previous_layer.get_proposition_layer()
        previous_layer_mutex_proposition = previous_proposition_layer.get_mutex_props()
        # build action layer
        self.update_action_layer(previous_proposition_layer)
        # mutex to actions
        self.update_mutex_actions(previous_layer_mutex_proposition)
        # set new prop layer and mutexes
        self.update_proposition_layer()
        self.update_mutex_proposition()

    def expand_without_mutex(self, previous_layer):
        """
        Questions 11 and 12
        You don't have to use this function
        """
        previous_proposition_layer = previous_layer.get_proposition_layer()
        previous_layer_mutex_proposition = previous_proposition_layer.get_mutex_props()
        # build action layer
        self.update_action_layer(previous_proposition_layer)
        # set new prop layer
        self.update_proposition_layer()
Exemplo n.º 5
0
class PlanGraphLevel(object):
    """
    A class for representing a level in the plan graph.
    For each level i, the PlanGraphLevel consists of the actionLayer and propositionLayer at this level in this order!
    """
    independent_actions = set(
    )  # updated to the independent_actions of the problem (graph_plan.py line 32)
    actions = [
    ]  # updated to the actions of the problem (graph_plan.py line 33 and planning_problem.py line 36)
    props = [
    ]  # updated to the propositions of the problem (graph_plan.py line 34 and planning_problem.py line 36)

    @staticmethod
    def set_independent_actions(independent_actions):
        PlanGraphLevel.independent_actions = independent_actions

    @staticmethod
    def set_actions(actions):
        PlanGraphLevel.actions = actions

    @staticmethod
    def set_props(props):
        PlanGraphLevel.props = props

    def __init__(self):
        """
        Constructor
        """
        self.action_layer = ActionLayer()  # see action_layer.py
        self.proposition_layer = PropositionLayer()  # see proposition_layer.py

    def get_proposition_layer(self):  # returns the proposition layer
        return self.proposition_layer

    def set_proposition_layer(self, prop_layer):  # sets the proposition layer
        self.proposition_layer = prop_layer

    def get_action_layer(self):  # returns the action layer
        return self.action_layer

    def set_action_layer(self, action_layer):  # sets the action layer
        self.action_layer = action_layer

    def update_action_layer(self, previous_proposition_layer):
        """
        Updates the action layer given the previous proposition layer (see proposition_layer.py)
        You should add an action to the layer if its preconditions are in the previous propositions layer,
        and the preconditions are not pairwise mutex.
        all_actions is the set of all the action (include noOp) in the domain
        You might want to use those functions:
        previous_proposition_layer.is_mutex(prop1, prop2) returns true
        if prop1 and prop2 are mutex at the previous propositions layer
        previous_proposition_layer.all_preconds_in_layer(action) returns true
        if all the preconditions of action are in the previous propositions layer
        self.actionLayer.addAction(action) adds action to the current action layer
        """
        all_actions = PlanGraphLevel.actions

        def admissible_act(action):
            if not previous_proposition_layer.all_preconds_in_layer(action):
                return False

            props = action.get_pre()

            for i in range(0, len(props)):
                for j in range(i + 1, len(props)):

                    prop_1 = props[i]
                    prop_2 = props[j]

                    if previous_proposition_layer.is_mutex(prop_1, prop_2):
                        return False

            return True

        for act in all_actions:
            if admissible_act(act):
                self.action_layer.add_action(act)

    def update_mutex_actions(self, previous_layer_mutex_proposition):
        """
        Updates the mutex set in self.action_layer,
        given the mutex proposition from the previous layer.
        current_layer_actions are the actions in the current action layer
        You might want to use this function:
        self.actionLayer.add_mutex_actions(action1, action2)
        adds the pair (action1, action2) to the mutex set in the current action layer
        Note that an action is *not* mutex with itself
        """
        current_layer_actions = list(self.action_layer.get_actions())

        for i in range(0, len(current_layer_actions)):
            for j in range(i + 1, len(current_layer_actions)):

                if mutex_actions(current_layer_actions[i],
                                 current_layer_actions[j],
                                 previous_layer_mutex_proposition):
                    self.action_layer.add_mutex_actions(
                        current_layer_actions[i], current_layer_actions[j])

    def update_proposition_layer(self):
        """
        Updates the propositions in the current proposition layer,
        given the current action layer.
        don't forget to update the producers list!
        Note that same proposition in different layers might have different producers lists,
        hence you should create two different instances.
        current_layer_actions is the set of all the actions in the current layer.
        You might want to use those functions:
        dict() creates a new dictionary that might help to keep track on the propositions that you've
               already added to the layer
        self.proposition_layer.add_proposition(prop) adds the proposition prop to the current layer

        """
        current_layer_actions = self.action_layer.get_actions()

        updated_props = {}

        # checks for every action and adds to the dictionary of updated props the acts that led to is
        for act in current_layer_actions:
            for prop in act.get_add():
                if prop not in updated_props:
                    updated_props[prop] = list()
                updated_props[prop].append(act)

        # create new Proposition and add it to the new layer
        for proposition in updated_props:

            # create new prop
            new_prop = Proposition(proposition.get_name())
            # add its producers
            new_prop.set_producers(updated_props[proposition][:])
            # add to new layer
            self.proposition_layer.add_proposition(new_prop)

    def update_mutex_proposition(self):
        """
        updates the mutex propositions in the current proposition layer
        You might want to use those functions:
        mutex_propositions(prop1, prop2, current_layer_mutex_actions) returns true
        if prop1 and prop2 are mutex in the current layer
        self.proposition_layer.add_mutex_prop(prop1, prop2) adds the pair (prop1, prop2)
        to the mutex set of the current layer
        """
        current_layer_propositions = list(
            self.proposition_layer.get_propositions())
        current_layer_mutex_actions = list(
            self.action_layer.get_mutex_actions())

        for i in range(0, len(current_layer_propositions)):
            for j in range(i + 1, len(current_layer_propositions)):
                if mutex_propositions(current_layer_propositions[i],
                                      current_layer_propositions[j],
                                      current_layer_mutex_actions):
                    self.proposition_layer.add_mutex_prop(
                        current_layer_propositions[i],
                        current_layer_propositions[j])

    def expand(self, previous_layer):
        """
        Your algorithm should work as follows:
        First, given the propositions and the list of mutex propositions from the previous layer,
        set the actions in the action layer.
        Then, set the mutex action in the action layer.
        Finally, given all the actions in the current layer,
        set the propositions and their mutex relations in the proposition layer.
        """
        previous_proposition_layer = previous_layer.get_proposition_layer()
        previous_layer_mutex_proposition = previous_proposition_layer.get_mutex_props(
        )
        # update the action layer with previous prop layer
        self.update_action_layer(previous_proposition_layer)
        # update the mutex action in cur layer
        self.update_mutex_actions(previous_layer_mutex_proposition)

        #update the proposition layer
        self.update_proposition_layer()

        #finally update mutex
        self.update_mutex_proposition()

    def expand_without_mutex(self, previous_layer):
        """
        Questions 11 and 12
        You don't have to use this function
        """
        previous_layer_proposition = previous_layer

        self.update_action_layer(previous_layer_proposition)
        self.update_proposition_layer()