Example #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!
    """
    independentActions = [
    ]  # updated to the independentActions of the propblem GraphPlan.py line 31
    actions = [
    ]  # updated to the actions of the problem GraphPlan.py line 32 and planningProblem.py line 25
    props = [
    ]  # updated to the propositions of the problem GraphPlan.py line 33 and planningProblem.py line 26

    @staticmethod
    def setIndependentActions(independentActions):
        PlanGraphLevel.independentActions = independentActions

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

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

    def __init__(self):
        """
        Constructor
        """
        self.actionLayer = ActionLayer()  # see actionLayer.py
        self.propositionLayer = PropositionLayer()  # see propositionLayer.py

    def getPropositionLayer(self):
        # returns the proposition layer
        return self.propositionLayer

    def setPropositionLayer(self, propLayer):
        # sets the proposition layer
        self.propositionLayer = propLayer

    def getActionLayer(self):
        # returns the action layer
        return self.actionLayer

    def setActionLayer(self, actionLayer):
        # sets the action layer
        self.actionLayer = actionLayer

    def updateActionLayer(self, previousPropositionLayer):
        """
        Updates the action layer given the previous proposition layer (see propositionLayer.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.
        allAction is the list of all the action (include noOp) in the domain
        You might want to use those functions:
        previousPropositionLayer.isMutex(prop1, prop2) returns true if prop1 and prop2 are mutex at the previous propositions layer
        previousPropositionLayer.allPrecondsInLayer(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
        """
        allActions = PlanGraphLevel.actions
        for action in allActions:
            if previousPropositionLayer.allPrecondsInLayer(action) \
                and True not in [previousPropositionLayer.isMutex(p1, p2) for p1, p2 in exclusiveProduct(action.getPre(), action.getPre())]:
                self.actionLayer.addAction(action)

    def updateMutexActions(self, previousLayerMutexProposition):
        """
        Updates the mutex list in self.actionLayer,
        given the mutex proposition from the previous layer.
        currentLayerActions are the actions in the current action layer
        You might want to use this function:
        self.actionLayer.addMutexActions(action1, action2)
        adds the pair (action1, action2) to the mutex list in the current action layer
        Note that action is *not* mutex with itself
        """
        currentLayerActions = self.actionLayer.getActions()
        actionPairs = exclusiveProduct(currentLayerActions,
                                       currentLayerActions)
        for a1, a2 in actionPairs:
            if mutexActions(a1, a2, previousLayerMutexProposition):
                self.actionLayer.addMutexActions(a1, a2)

    def updatePropositionLayer(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.
        currentLayerActions is the list 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.propositionLayer.addProposition(prop) adds the proposition prop to the current layer
        """

        currentLayerActions = self.actionLayer.getActions()
        props = dict()

        for a in currentLayerActions:
            for prop in a.getAdd():
                name = prop.getName()
                if name not in props.keys():
                    props[name] = Proposition(name)
                props[name].addProducer(a)

        for prop in props.values():
            self.propositionLayer.addProposition(prop)

    def updateMutexProposition(self):
        """
        updates the mutex propositions in the current proposition layer
        You might want to use those functions:
        mutexPropositions(prop1, prop2, currentLayerMutexActions) returns true if prop1 and prop2 are mutex in the current layer
        self.propositionLayer.addMutexProp(prop1, prop2) adds the pair (prop1, prop2) to the mutex list of the current layer
        """
        currentLayerPropositions = self.propositionLayer.getPropositions()
        currentLayerMutexActions = self.actionLayer.getMutexActions()
        for p1, p2 in exclusiveProduct(currentLayerPropositions,
                                       currentLayerPropositions):
            if mutexPropositions(p1, p2, currentLayerMutexActions):
                self.propositionLayer.addMutexProp(p1, p2)

    def expand(self, previousLayer):
        """
        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.
        """
        previousPropositionLayer = previousLayer.getPropositionLayer()
        previousLayerMutexProposition = previousPropositionLayer.getMutexProps(
        )
        self.updateActionLayer(previousPropositionLayer)
        self.updateMutexActions(previousLayerMutexProposition)
        self.updatePropositionLayer()
        self.updateMutexProposition()

    def expandWithoutMutex(self, previousLayer):
        """
        Expand the graph without updating the mutex relations
        """
        previousPropositionLayer = previousLayer.getPropositionLayer()
        self.updateActionLayer(previousPropositionLayer)
        self.updatePropositionLayer()
Example #2
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!
  """
  independentActions = []  # updated to the independentActions of the propblem GraphPlan.py line 31 
  actions = []             # updated to the actions of the problem GraphPlan.py line 32 and planningProblem.py line 25
  props = []               # updated to the propositions of the problem GraphPlan.py line 33 and planningProblem.py line 26
  
  @staticmethod
  def setIndependentActions(independentActions):
    PlanGraphLevel.independentActions = independentActions
  
  @staticmethod  
  def setActions(actions):
    PlanGraphLevel.actions = actions
  
  @staticmethod    
  def setProps(props):
    PlanGraphLevel.props = props   
  
  def __init__(self):
    """
    Constructor
    """
    self.actionLayer = ActionLayer()    		    # see actionLayer.py
    self.propositionLayer = PropositionLayer()	# see propositionLayer.py
  
  def getPropositionLayer(self):
  # returns the proposition layer
    return self.propositionLayer
  
  def setPropositionLayer(self, propLayer):
  # sets the proposition layer
    self.propositionLayer = propLayer  
  
  def getActionLayer(self):
  # returns the action layer
    return self.actionLayer
    
  def setActionLayer(self, actionLayer):
  # sets the action layer
    self.actionLayer = actionLayer

  def updateActionLayer(self, previousPropositionLayer):
    """ 
    Updates the action layer given the previous proposition layer (see propositionLayer.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. 
    allAction is the list of all the action (include noOp) in the domain
    You might want to use those functions:
    previousPropositionLayer.isMutex(prop1, prop2) returns true if prop1 and prop2 are mutex at the previous propositions layer
    previousPropositionLayer.allPrecondsInLayer(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
    """ 
    allActions = PlanGraphLevel.actions
    "*** YOUR CODE HERE ***"
    for action in allActions:
      #check the preconditions
      if previousPropositionLayer.allPrecondsInLayer(action):
        actionPropositions = action.getPre()
        #check the mutex
        isNotMutex = True
        for prop1 in actionPropositions:
          for prop2 in actionPropositions:
            if not prop1 == prop2:
              if previousPropositionLayer.isMutex(prop1, prop2):
                isNotMutex = False
        if isNotMutex:
          self.actionLayer.addAction(action)


    
  def updateMutexActions(self, previousLayerMutexProposition):
    """
    Updates the mutex list in self.actionLayer,
    given the mutex proposition from the previous layer.
    currentLayerActions are the actions in the current action layer
    You might want to use this function:
    self.actionLayer.addMutexActions(action1, action2)
    adds the pair (action1, action2) to the mutex list in the current action layer
    Note that action is *not* mutex with itself
    """
    currentLayerActions = self.actionLayer.getActions()
    "*** YOUR CODE HERE ***"
    for action1 in currentLayerActions:
      for action2 in currentLayerActions:
        if (not action1 == action2) and\
            (Pair(action1,action2) not in self.actionLayer.getMutexActions()):
          if mutexActions(action1, action2, previousLayerMutexProposition):
            self.actionLayer.addMutexActions(action1, action2)
    
  def updatePropositionLayer(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.
    currentLayerActions is the list 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.propositionLayer.addProposition(prop) adds the proposition prop to the current layer       
    
    """
    currentLayerActions = self.actionLayer.getActions()
    "*** YOUR CODE HERE ***"
    # create dictionary with proposition and actions
    # leading to it
    propositionDict = dict()
    for action in currentLayerActions:
      for prop in action.getAdd():
        if prop.getName() in propositionDict.keys():
          propositionDict[prop.getName()].append(action)
        else:
          actionList = list()
          actionList.append(action)
          propositionDict.update({prop.getName(): actionList})

    #create proposition object and update their actions
    for key in propositionDict.keys():
      p = Proposition(key)
      p.setProducers(propositionDict[key])
      self.propositionLayer.addProposition(p)

    
  def updateMutexProposition(self):
    """
    updates the mutex propositions in the current proposition layer
    You might want to use those functions:
    mutexPropositions(prop1, prop2, currentLayerMutexActions) returns true if prop1 and prop2 are mutex in the current layer
    self.propositionLayer.addMutexProp(prop1, prop2) adds the pair (prop1, prop2) to the mutex list of the current layer
    """
    currentLayerPropositions = self.propositionLayer.getPropositions()
    currentLayerMutexActions =  self.actionLayer.getMutexActions()
    "*** YOUR CODE HERE ***"
    for prop1 in currentLayerPropositions:
      for prop2 in currentLayerPropositions:
        if not prop1 == prop2 and \
            (Pair(prop1, prop2) not in self.propositionLayer.getMutexProps()):
          if mutexPropositions(prop1, prop2, currentLayerMutexActions):
            self.propositionLayer.addMutexProp(prop1, prop2)

    
  def expand(self, previousLayer):
    """
    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.   
    """
    previousPropositionLayer = previousLayer.getPropositionLayer()
    previousLayerMutexProposition = previousPropositionLayer.getMutexProps()

    "*** YOUR CODE HERE ***"
    self.updateActionLayer(previousPropositionLayer)
    self.updateMutexActions(previousLayerMutexProposition)
    self.updatePropositionLayer()
    self.updateMutexProposition()



  def expandWithoutMutex(self, previousLayer):
    """
    Questions 11 and 12
    You don't have to use this function
    """
    previousLayerProposition = previousLayer.getPropositionLayer()
    "*** YOUR CODE HERE ***"
    self.updateActionLayer(previousLayerProposition)
    self.updatePropositionLayer()
Example #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!
    """
    independentActions = []  # updated to the independentActions of the propblem GraphPlan.py line 31
    actions = []             # updated to the actions of the problem GraphPlan.py line 32 and planningProblem.py line 25
    props = []               # updated to the propositions of the problem GraphPlan.py line 33 and planningProblem.py line 26

    @staticmethod
    def setIndependentActions(independentActions):
        PlanGraphLevel.independentActions = independentActions

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

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

    def __init__(self):
        """
        Constructor
        """
        self.actionLayer = ActionLayer()                        # see actionLayer.py
        self.propositionLayer = PropositionLayer()  # see propositionLayer.py

    def getPropositionLayer(self):
    # returns the proposition layer
        return self.propositionLayer

    def setPropositionLayer(self, propLayer):
    # sets the proposition layer
        self.propositionLayer = propLayer

    def getActionLayer(self):
    # returns the action layer
        return self.actionLayer

    def setActionLayer(self, actionLayer):
    # sets the action layer
        self.actionLayer = actionLayer

    def updateActionLayer(self, previousPropositionLayer):
        """
        Updates the action layer given the previous proposition layer (see propositionLayer.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.
        allAction is the list of all the action (include noOp) in the domain
        You might want to use those functions:
        previousPropositionLayer.isMutex(prop1, prop2) returns true if prop1 and prop2 are mutex at the previous propositions layer
        previousPropositionLayer.allPrecondsInLayer(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
        """
        allActions = PlanGraphLevel.actions        
        for action in allActions:
            if previousPropositionLayer.allPrecondsInLayer(action) \
                and True not in [previousPropositionLayer.isMutex(p1, p2) for p1, p2 in exclusiveProduct(action.getPre(), action.getPre())]:
                self.actionLayer.addAction(action)
            
    def updateMutexActions(self, previousLayerMutexProposition):
        """
        Updates the mutex list in self.actionLayer,
        given the mutex proposition from the previous layer.
        currentLayerActions are the actions in the current action layer
        You might want to use this function:
        self.actionLayer.addMutexActions(action1, action2)
        adds the pair (action1, action2) to the mutex list in the current action layer
        Note that action is *not* mutex with itself
        """
        currentLayerActions = self.actionLayer.getActions()        
        actionPairs = exclusiveProduct(currentLayerActions, currentLayerActions)
        for a1, a2 in actionPairs:
            if mutexActions(a1, a2, previousLayerMutexProposition):
                self.actionLayer.addMutexActions(a1, a2)
        
    def updatePropositionLayer(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.
        currentLayerActions is the list 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.propositionLayer.addProposition(prop) adds the proposition prop to the current layer
        """
        
        currentLayerActions = self.actionLayer.getActions()
        props = dict()
                        
        for a in currentLayerActions:
            for prop in a.getAdd():
                name = prop.getName()
                if name not in props.keys():
                    props[name] = Proposition(name)
                props[name].addProducer(a)
        
        for prop in props.values():
            self.propositionLayer.addProposition(prop)

    def updateMutexProposition(self):
        """
        updates the mutex propositions in the current proposition layer
        You might want to use those functions:
        mutexPropositions(prop1, prop2, currentLayerMutexActions) returns true if prop1 and prop2 are mutex in the current layer
        self.propositionLayer.addMutexProp(prop1, prop2) adds the pair (prop1, prop2) to the mutex list of the current layer
        """
        currentLayerPropositions = self.propositionLayer.getPropositions()
        currentLayerMutexActions = self.actionLayer.getMutexActions()
        for p1, p2 in exclusiveProduct(currentLayerPropositions, currentLayerPropositions):
            if mutexPropositions(p1, p2, currentLayerMutexActions):
                self.propositionLayer.addMutexProp(p1, p2)

    def expand(self, previousLayer):
        """
        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.
        """
        previousPropositionLayer = previousLayer.getPropositionLayer()
        previousLayerMutexProposition = previousPropositionLayer.getMutexProps()
        self.updateActionLayer(previousPropositionLayer)
        self.updateMutexActions(previousLayerMutexProposition)
        self.updatePropositionLayer()
        self.updateMutexProposition()

    def expandWithoutMutex(self, previousLayer):
        """
        Expand the graph without updating the mutex relations
        """
        previousPropositionLayer = previousLayer.getPropositionLayer()
        self.updateActionLayer(previousPropositionLayer)
        self.updatePropositionLayer()
Example #4
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!
    """
    independentActions = []  # updated to the independentActions of the propblem GraphPlan.py line 31
    actions = []  # updated to the actions of the problem GraphPlan.py line 32 and planningProblem.py line 25
    props = []  # updated to the propositions of the problem GraphPlan.py line 33 and planningProblem.py line 26

    @staticmethod
    def setIndependentActions(independentActions):
        PlanGraphLevel.independentActions = independentActions

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

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

    def __init__(self):
        """
        Constructor
        """
        self.actionLayer = ActionLayer()  # see actionLayer.py
        self.propositionLayer = PropositionLayer()  # see propositionLayer.py

    def getPropositionLayer(self):
        # returns the proposition layer
        return self.propositionLayer

    def setPropositionLayer(self, propLayer):
        # sets the proposition layer
        self.propositionLayer = propLayer

    def getActionLayer(self):
        # returns the action layer
        return self.actionLayer

    def setActionLayer(self, actionLayer):
        # sets the action layer
        self.actionLayer = actionLayer

    def updateActionLayer(self, previousPropositionLayer):
        """
        Updates the action layer given the previous proposition layer (see propositionLayer.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.
        allAction is the list of all the action (include noOp) in the domain
        You might want to use those functions:
        previousPropositionLayer.isMutex(prop1, prop2) returns true if prop1 and prop2 are mutex at the previous propositions layer
        previousPropositionLayer.allPrecondsInLayer(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
        """
        allActions = PlanGraphLevel.actions

        for action in allActions:
            if previousPropositionLayer.allPrecondsInLayer(action) and\
                    not pre_contains_pairwise_mutex(action, previousPropositionLayer):
                self.actionLayer.addAction(action)

    def updateMutexActions(self, previousLayerMutexProposition):
        """
        Updates the mutex list in self.actionLayer,
        given the mutex proposition from the previous layer.
        currentLayerActions are the actions in the current action layer
        You might want to use this function:
        self.actionLayer.addMutexActions(action1, action2)
        adds the pair (action1, action2) to the mutex list in the current action layer
        Note that action is *not* mutex with itself
        """
        currentLayerActions = self.actionLayer.getActions()

        for action1 in currentLayerActions:
                for action2 in currentLayerActions:
                    if action1 != action2 and\
                            mutexActions(action1, action2, previousLayerMutexProposition):
                        self.actionLayer.addMutexActions(action1, action2)



    def updatePropositionLayer(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.
        currentLayerActions is the list 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.propositionLayer.addProposition(prop) adds the proposition prop to the current layer

        """
        currentLayerActions = self.actionLayer.getActions()
        props_dict = dict()
        for action in currentLayerActions:
            for add_props in action.getAdd():
                if add_props.getName() not in props_dict:
                    props_dict[add_props.getName()] = [action]
                else:
                    props_dict[add_props.getName()] = \
                        props_dict[add_props.getName()]+[action]

        for key in props_dict:
            prop_temp = Proposition(key)
            prop_temp.setProducers(props_dict[key])    #takes care of adding procedure
            self.propositionLayer.addProposition(prop_temp)
        #notice there is no mention of mutexes. is this ok?


    def updateMutexProposition(self):
        """
        updates the mutex propositions in the current proposition layer
        You might want to use those functions:
        mutexPropositions(prop1, prop2, currentLayerMutexActions) returns true if prop1 and prop2 are mutex in the current layer
        self.propositionLayer.addMutexProp(prop1, prop2) adds the pair (prop1, prop2) to the mutex list of the current layer
        """
        currentLayerPropositions = self.propositionLayer.getPropositions()
        currentLayerMutexActions = self.actionLayer.getMutexActions()
        for prop1 in currentLayerPropositions:
            for prop2 in currentLayerPropositions:
                if mutexPropositions(prop1, prop2, currentLayerMutexActions) \
                        and prop1 != prop2:
                    self.propositionLayer.addMutexProp(prop1, prop2)



    def expand(self, previousLayer):
        """
        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.
        """
        previousPropositionLayer = previousLayer.getPropositionLayer()
        previousLayerMutexProposition = previousPropositionLayer.getMutexProps()

        self.updateActionLayer(previousPropositionLayer)
        self.updateMutexActions(previousLayerMutexProposition)

        self.updatePropositionLayer()
        self.updateMutexProposition()

    def expandWithoutMutex(self, previousLayer):
        """
        Questions 11 and 12
        You don't have to use this function
        """

        previousPropositionLayer = previousLayer.getPropositionLayer()

        self.updateActionLayer(previousPropositionLayer)

        self.updatePropositionLayer()
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!
  """
    independentActions = [
    ]  # updated to the independentActions of the propblem GraphPlan.py line 31
    actions = [
    ]  # updated to the actions of the problem GraphPlan.py line 32 and planningProblem.py line 25
    props = [
    ]  # updated to the propositions of the problem GraphPlan.py line 33 and planningProblem.py line 26

    @staticmethod
    def setIndependentActions(independentActions):
        PlanGraphLevel.independentActions = independentActions

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

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

    def __init__(self):
        """
    Constructor
    """
        self.actionLayer = ActionLayer()  # see actionLayer.py
        self.propositionLayer = PropositionLayer()  # see propositionLayer.py

    def getPropositionLayer(self):
        # returns the proposition layer
        return self.propositionLayer

    def setPropositionLayer(self, propLayer):
        # sets the proposition layer
        self.propositionLayer = propLayer

    def getActionLayer(self):
        # returns the action layer
        return self.actionLayer

    def setActionLayer(self, actionLayer):
        # sets the action layer
        self.actionLayer = actionLayer

    def updateActionLayer(self, previousPropositionLayer):
        """ 
    Updates the action layer given the previous proposition layer (see propositionLayer.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. 
    allAction is the list of all the action (include noOp) in the domain
    You might want to use those functions:
    previousPropositionLayer.isMutex(prop1, prop2) returns true if prop1 and prop2 are mutex at the previous propositions layer
    previousPropositionLayer.allPrecondsInLayer(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
    """
        allActions = PlanGraphLevel.actions
        for action in allActions:
            if previousPropositionLayer.allPrecondsInLayer(
                    action) and action not in self.actionLayer.getActions():
                self.actionLayer.addAction(action)

    def updateMutexActions(self, previousLayerMutexProposition):
        """
    Updates the mutex list in self.actionLayer,
    given the mutex proposition from the previous layer.
    currentLayerActions are the actions in the current action layer
    You might want to use this function:
    self.actionLayer.addMutexActions(action1, action2)
    adds the pair (action1, action2) to the mutex list in the current action layer
    Note that action is *not* mutex with itself
    """
        currentLayerActions = self.actionLayer.getActions()
        for a1 in currentLayerActions:
            for a2 in currentLayerActions:
                if a1 == a2:
                    continue  # an action is not mutex with itself

                if Pair(a1, a2) not in self.actionLayer.getMutexActions(
                ) and mutexActions(a1, a2, previousLayerMutexProposition):
                    # if a1 and a2 are mutex actions, and we didn't add them before, we should do so now
                    self.actionLayer.addMutexActions(a1, a2)

    def updatePropositionLayer(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.
    currentLayerActions is the list 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.propositionLayer.addProposition(prop) adds the proposition prop to the current layer       
    
    """
        currentLayerActions = self.actionLayer.getActions()
        for action in currentLayerActions:
            for p in action.getAdd():
                # add the proposition if it doesn't already exist
                if p not in self.propositionLayer.getPropositions():
                    self.propositionLayer.addProposition(p)

                # add the action as a producer if it doesn't already exist
                if action not in p.getProducers():
                    p.addProducer(action)

    def updateMutexProposition(self):
        """
    updates the mutex propositions in the current proposition layer
    You might want to use those functions:
    mutexPropositions(prop1, prop2, currentLayerMutexActions) returns true if prop1 and prop2 are mutex in the current layer
    self.propositionLayer.addMutexProp(prop1, prop2) adds the pair (prop1, prop2) to the mutex list of the current layer
    """
        currentLayerPropositions = self.propositionLayer.getPropositions()
        currentLayerMutexActions = self.actionLayer.getMutexActions()
        for p in currentLayerPropositions:
            for q in currentLayerPropositions:
                if p == q:
                    continue  # a proposition is not mutex with itself

                if Pair(p, q) not in self.propositionLayer.getMutexProps(
                ) and mutexPropositions(p, q, currentLayerMutexActions):
                    # if p and q are mutex props, and we didn't add them before, we should do so now
                    self.propositionLayer.addMutexProp(p, q)

    def expand(self, previousLayer):
        """
    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.   
    """
        previousPropositionLayer = previousLayer.getPropositionLayer()
        previousLayerMutexProposition = previousPropositionLayer.getMutexProps(
        )

        self.updateActionLayer(previousPropositionLayer)
        self.updateMutexActions(previousLayerMutexProposition)
        self.updatePropositionLayer()
        self.updateMutexProposition()

    def expandWithoutMutex(self, previousLayer):
        """
    Questions 11 and 12
    You don't have to use this function
    """
        previousLayerProposition = previousLayer.getPropositionLayer()
        self.updateActionLayer(previousLayerProposition)
        self.updatePropositionLayer()
Example #6
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!
  """
  independentActions = None                                               # updated to the independentActions of the propblem GraphPlan.py line 25
  actions = None                                                          # updated to the actions of the problem GraphPlan.py line 26 and planningProblem.py line 25
  props = None                                                            # updated to the propositions of the problem GraphPlan.py line 27 and planningProblem.py line 26
  
  @staticmethod
  def setIndependentActions(independentActions):
    PlanGraphLevel.independentActions = independentActions
  
  @staticmethod  
  def setActions(actions):
    PlanGraphLevel.actions = actions
  
  @staticmethod    
  def setProps(props):
    PlanGraphLevel.props = props   
  
  def __init__(self):
    """
    Constructor
    """
    self.actionLayer = ActionLayer()    		                            # see actionLayer.py
    self.propositionLayer = PropositionLayer()	                        # see propositionLayer.py
  
  def getPropositionLayer(self):                                        # returns the proposition layer

    return self.propositionLayer
  
  def setPropositionLayer(self, propLayer):                             # sets the proposition layer
    self.propositionLayer = propLayer  
  
  def getActionLayer(self):                                             # returns the action layer
    return self.actionLayer
    
  def setActionLayer(self, actionLayer):                                # sets the action layer
    self.actionLayer = actionLayer

  def updateActionLayer(self, previousPropositionLayer):
    """ 
    Updates the action layer given the previous proposition layer (see propositionLayer.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. 
    allAction is the set of all the action (include noOp) in the domain
    You might want to use those functions:
    previousPropositionLayer.isMutex(prop1, prop2) returns true if prop1 and prop2 are mutex at the previous propositions layer
    previousPropositionLayer.allPrecondsInLayer(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
    """ 
    allActions = PlanGraphLevel.actions
    for action in allActions:
      if previousPropositionLayer.allPrecondsInLayer(action):
        pre = action.getPre()
        add = True
        for prop1 in pre:
          for prop2 in pre:
            if prop1 != prop2 and previousPropositionLayer.isMutex(prop1, prop2):
              add = False
              break
          if not add:
            break
        if add:
          self.actionLayer.addAction(action)

              


    
  def updateMutexActions(self, previousLayerMutexProposition):
    """
    Updates the mutex set in self.actionLayer,
    given the mutex proposition from the previous layer.
    currentLayerActions are the actions in the current action layer
    You might want to use this function:
    self.actionLayer.addMutexActions(action1, action2)
    adds the pair (action1, action2) to the mutex set in the current action layer
    Note that action is *not* mutex with itself
    """
    currentLayerActions = self.actionLayer.getActions()
    for a1 in  currentLayerActions:
      for a2 in currentLayerActions:
        if(a1 == a2):
          continue
        elif haveCompetingNeeds(a1, a2, previousLayerMutexProposition):
           self.actionLayer.addMutexActions(a1, a2)
    
    
  def updatePropositionLayer(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.
    currentLayerActions 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.propositionLayer.addProposition(prop) adds the proposition prop to the current layer       
    
    """
    currentLayerActions = self.actionLayer.getActions()
    propostions = {}
    for action in currentLayerActions:
      for prop in action.getAdd():
        if not prop.getName() in propostions:
          newProp = Proposition(prop.getName())
          propostions[prop.getName()] = newProp

        propostions[prop.getName()].addProducer(action)

    for prop in propostions:
      self.propositionLayer.addProposition(propostions[prop])
    
  def updateMutexProposition(self):
    """
    updates the mutex propositions in the current proposition layer
    You might want to use those functions:
    mutexPropositions(prop1, prop2, currentLayerMutexActions) returns true if prop1 and prop2 are mutex in the current layer
    self.propositionLayer.addMutexProp(prop1, prop2) adds the pair (prop1, prop2) to the mutex set of the current layer
    """
    currentLayerPropositions = self.propositionLayer.getPropositions()
    currentLayerMutexActions =  self.actionLayer.getMutexActions()

    for prop1 in currentLayerPropositions:
      for prop2 in currentLayerPropositions:
        if prop1 == prop2:
          continue
        elif mutexPropositions(prop1, prop2, currentLayerMutexActions):
          self.propositionLayer.addMutexProp(prop1, prop2)


  def expand(self, previousLayer):
    """
    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.   
    """
    previousPropositionLayer = previousLayer.getPropositionLayer()
    previousLayerMutexProposition = previousPropositionLayer.getMutexProps()
    self.updateActionLayer(previousPropositionLayer)
    self.updateMutexActions(previousLayerMutexProposition)
    self.updatePropositionLayer()
    self.updateMutexProposition()
            
  def expandWithoutMutex(self, previousLayer):
    """
    Questions 11 and 12
    You don't have to use this function
    """
    previousLayerProposition = previousLayer.getPropositionLayer()
    self.updateActionLayer(previousLayerProposition)
    self.updatePropositionLayer()
Example #7
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!
  """
  independentActions = []  # updated to the independentActions of the propblem GraphPlan.py line 31
  actions = []             # updated to the actions of the problem GraphPlan.py line 32 and planningProblem.py line 25
  props = []               # updated to the propositions of the problem GraphPlan.py line 33 and planningProblem.py line 26

  @staticmethod
  def setIndependentActions(independentActions):
    PlanGraphLevel.independentActions = independentActions

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

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

  def __init__(self):
    """
    Constructor
    """
    self.actionLayer = ActionLayer()    		# see actionLayer.py
    self.propositionLayer = PropositionLayer()	# see propositionLayer.py


  def getPropositionLayer(self):
    return self.propositionLayer

  def setPropositionLayer(self, propLayer):
    self.propositionLayer = propLayer

  def getActionLayer(self):
    return self.actionLayer

  def setActionLayer(self, actionLayer):
    self.actionLayer = actionLayer

  def updateActionLayer(self, previousPropositionLayer):
    """
    Updates the action layer given the previous proposition layer (see propositionLayer.py)
    allAction is the list of all the action (include noOp in the domain)
    """
    allActions = PlanGraphLevel.actions
    for action in allActions:
      if previousPropositionLayer.allPrecondsInLayer(action):
        self.actionLayer.addAction(action)
        for p1 in action.getPre():
          for p2 in action.getPre():
            if previousPropositionLayer.isMutex(p1, p2):
              self.actionLayer.removeActions(action)

  def updateMutexActions(self, previousLayerMutexProposition):
    """
    Updates the mutex list in self.actionLayer,
    given the mutex proposition from the previous layer.
    currentLayerActions are the actions in the current action layer
    """
    currentLayerActions = self.actionLayer.getActions()
    for a1 in currentLayerActions:
      for a2 in currentLayerActions:
        if a1 == a2:
          continue
        if mutexActions(a1, a2, previousLayerMutexProposition):
          self.actionLayer.addMutexActions(a1, a2)


  def updatePropositionLayer(self):
    """
    Updates the propositions in the current proposition layer,
    given the current action layer.
    don't forget to update the producers list!
    """
    currentLayerActions = self.actionLayer.getActions()
    propsToAdd = dict()
    for action in currentLayerActions:
      for prop in action.getAdd():
        if prop.getName() not in propsToAdd:
          propsToAdd[prop.getName()] = Proposition(prop.getName())
        temp = propsToAdd[prop.getName()]
        if action not in temp.getProducers():
          temp.addProducer(action)
    for prop in propsToAdd.values():
      self.propositionLayer.addProposition(prop)

  def updateMutexProposition(self):
    """
    updates the mutex propositions in the current proposition layer
    """
    currentLayerPropositions = self.propositionLayer.getPropositions()
    currentLayerMutexActions =  self.actionLayer.getMutexActions()
    for prop1 in currentLayerPropositions:
      for prop2 in currentLayerPropositions:
        if prop1 == prop2:
          continue
        if mutexPropositions(prop1, prop2, currentLayerMutexActions):
          self.propositionLayer.addMutexProp(prop1, prop2)


  def expand(self, previousLayer):
    """
    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.
    """
    previousPropositionLayer = previousLayer.getPropositionLayer()
    previousLayerMutexProposition = previousPropositionLayer.getMutexProps()

    self.updateActionLayer(previousPropositionLayer)
    self.updateMutexActions(previousLayerMutexProposition)
    self.updatePropositionLayer()
    self.updateMutexProposition()


  def expandWithoutMutex(self, previousLayer):
    """
    Questions 11 and 12
    You don't have to use this function
    """
    previousLayerProposition = previousLayer.getPropositionLayer()
    "*** YOUR CODE HERE ***"
Example #8
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!
  """
    independentActions = [
    ]  # updated to the independentActions of the propblem GraphPlan.py line 31
    actions = [
    ]  # updated to the actions of the problem GraphPlan.py line 32 and planningProblem.py line 25
    props = [
    ]  # updated to the propositions of the problem GraphPlan.py line 33 and planningProblem.py line 26

    @staticmethod
    def setIndependentActions(independentActions):
        PlanGraphLevel.independentActions = independentActions

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

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

    def __init__(self):
        """
    Constructor
    """
        self.actionLayer = ActionLayer()  # see actionLayer.py
        self.propositionLayer = PropositionLayer()  # see propositionLayer.py

    def getPropositionLayer(self):
        # returns the proposition layer
        return self.propositionLayer

    def setPropositionLayer(self, propLayer):
        # sets the proposition layer
        self.propositionLayer = propLayer

    def getActionLayer(self):
        # returns the action layer
        return self.actionLayer

    def setActionLayer(self, actionLayer):
        # sets the action layer
        self.actionLayer = actionLayer

    def updateActionLayer(self, previousPropositionLayer):
        """ 
    Updates the action layer given the previous proposition layer (see propositionLayer.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. 
    allAction is the list of all the action (include noOp) in the domain
    You might want to use those functions:
    previousPropositionLayer.isMutex(prop1, prop2) returns true if prop1 and prop2 are mutex at the previous propositions layer
    previousPropositionLayer.allPrecondsInLayer(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
    """
        allActions = PlanGraphLevel.actions
        "*** YOUR CODE HERE ***"

        for action in allActions:
            if previousPropositionLayer.allPrecondsInLayer(action):
                self.actionLayer.addAction(action)

    def updateMutexActions(self, previousLayerMutexProposition):
        """
    Updates the mutex list in self.actionLayer,
    given the mutex proposition from the previous layer.
    currentLayerActions are the actions in the current action layer
    You might want to use this function:
    self.actionLayer.addMutexActions(action1, action2)
    adds the pair (action1, action2) to the mutex list in the current action layer
    Note that action is *not* mutex with itself
    """
        currentLayerActions = self.actionLayer.getActions()
        "*** YOUR CODE HERE ***"

        index = 0
        for action1 in currentLayerActions:
            index += 1
            for action2 in currentLayerActions[index:]:

                is_mutex = False
                for pre1 in action1.getPre():
                    for pre2 in action2.getPre():
                        if Pair(pre1, pre2) in previousLayerMutexProposition:
                            is_mutex = True
                            break

                if Pair(action1, action2) not in self.independentActions:
                    is_mutex = True

                if is_mutex:
                    self.actionLayer.addMutexActions(action1, action2)

    def updatePropositionLayer(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.
    currentLayerActions is the list 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.propositionLayer.addProposition(prop) adds the proposition prop to the current layer       
    
    """
        currentLayerActions = self.actionLayer.getActions()
        "*** YOUR CODE HERE ***"

        Propositions = dict()

        for action in currentLayerActions:
            for prop in action.getAdd():

                name = prop.getName()
                if Propositions.has_key(name):
                    new_prop = Propositions[name]
                else:
                    new_prop = Proposition(name)
                    Propositions[name] = new_prop
                    self.propositionLayer.addProposition(new_prop)

                new_prop.addProducer(action)

    def updateMutexProposition(self):
        """
    updates the mutex propositions in the current proposition layer
    You might want to use those functions:
    mutexPropositions(prop1, prop2, currentLayerMutexActions) returns true if prop1 and prop2 are mutex in the current layer
    self.propositionLayer.addMutexProp(prop1, prop2) adds the pair (prop1, prop2) to the mutex list of the current layer
    """
        currentLayerPropositions = self.propositionLayer.getPropositions()
        currentLayerMutexActions = self.actionLayer.getMutexActions()
        "*** YOUR CODE HERE ***"

        index = 0
        for prop1 in currentLayerPropositions:
            index += 1
            for prop2 in currentLayerPropositions[index:]:
                if mutexPropositions(prop1, prop2, currentLayerMutexActions):
                    self.propositionLayer.addMutexProp(prop1, prop2)

    def expand(self, previousLayer):
        """
    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.   
    """
        previousPropositionLayer = previousLayer.getPropositionLayer()
        previousLayerMutexProposition = previousPropositionLayer.getMutexProps(
        )

        "*** YOUR CODE HERE ***"

        self.updateActionLayer(previousPropositionLayer)
        self.updateMutexActions(previousLayerMutexProposition)
        self.updatePropositionLayer()
        self.updateMutexProposition()

        #print('expand')
        #print('actions              ' + str([action.getName() for action in self.actionLayer.actions]))
        #print('propositions         ' + str([prop.getName() for prop in self.propositionLayer.propositions]))
        #print('actions mutexes      ' + str([pair.a.getName()+","+pair.b.getName() for pair in self.actionLayer.mutexActions]))
        #print('propositions mutexes ' +  str([pair.a.getName()+","+pair.b.getName() for pair in self.propositionLayer.mutexPropositions]))

    def expandWithoutMutex(self, previousLayer):
        """
    Questions 11 and 12
    You don't have to use this function
    """
        previousLayerProposition = previousLayer.getPropositionLayer()
        "*** YOUR CODE HERE ***"

        self.updateActionLayer(previousLayerProposition)
        self.updatePropositionLayer()
Example #9
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!
  """
    independentActions = [
    ]  # updated to the independentActions of the propblem GraphPlan.py line 31
    actions = [
    ]  # updated to the actions of the problem GraphPlan.py line 32 and planningProblem.py line 25
    props = [
    ]  # updated to the propositions of the problem GraphPlan.py line 33 and planningProblem.py line 26

    @staticmethod
    def setIndependentActions(independentActions):
        PlanGraphLevel.independentActions = independentActions

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

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

    def __init__(self):
        """
    Constructor
    """
        self.actionLayer = ActionLayer()  # see actionLayer.py
        self.propositionLayer = PropositionLayer()  # see propositionLayer.py

    def getPropositionLayer(self):
        # returns the proposition layer
        return self.propositionLayer

    def setPropositionLayer(self, propLayer):
        # sets the proposition layer
        self.propositionLayer = propLayer

    def getActionLayer(self):
        # returns the action layer
        return self.actionLayer

    def setActionLayer(self, actionLayer):
        # sets the action layer
        self.actionLayer = actionLayer

    def updateActionLayer(self, previousPropositionLayer):
        """ 
    Updates the action layer given the previous proposition layer (see propositionLayer.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. 
    allAction is the list of all the action (include noOp) in the domain
    You might want to use those functions:
    previousPropositionLayer.isMutex(prop1, prop2) returns true if prop1 and prop2 are mutex at the previous propositions layer
    previousPropositionLayer.allPrecondsInLayer(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
    """
        allActions = PlanGraphLevel.actions
        # For each action that is not in this actionLayer and was in the previous one. We will add it to this layer too (as noOp)
        for action in allActions:
            if action not in self.actionLayer.getActions(
            ) and previousPropositionLayer.allPrecondsInLayer(action):
                self.actionLayer.addAction(action)

    def updateMutexActions(self, previousLayerMutexProposition):
        """
    Updates the mutex list in self.actionLayer,
    given the mutex proposition from the previous layer.
    currentLayerActions are the actions in the current action layer
    You might want to use this function:
    self.actionLayer.addMutexActions(action1, action2)
    adds the pair (action1, action2) to the mutex list in the current action layer
    Note that action is *not* mutex with itself
    """
        currentLayerActions = self.actionLayer.getActions()
        for ai in currentLayerActions:
            for aj in currentLayerActions:
                # For each action 1,2 in current action layer, if they are mutex, and they are not in mutex actions, we will ad them too.
                if ai != aj and \
                  Pair(ai, aj) not in self.actionLayer.getMutexActions() and \
                  mutexActions(ai, aj, previousLayerMutexProposition):
                    self.actionLayer.addMutexActions(ai, aj)

    def updatePropositionLayer(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.
    currentLayerActions is the list 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.propositionLayer.addProposition(prop) adds the proposition prop to the current layer       
    
    """
        currentLayerActions = self.actionLayer.getActions()
        for action in currentLayerActions:
            for prop in action.getAdd():
                if prop not in self.propositionLayer.getPropositions():
                    self.propositionLayer.addProposition(prop)
                # updating action's producers
                if action not in prop.getProducers():
                    prop.addProducer(action)

    def updateMutexProposition(self):
        """
    updates the mutex propositions in the current proposition layer
    You might want to use those functions:
    mutexPropositions(prop1, prop2, currentLayerMutexActions) returns true if prop1 and prop2 are mutex in the current layer
    self.propositionLayer.addMutexProp(prop1, prop2) adds the pair (prop1, prop2) to the mutex list of the current layer
    """
        currentLayerPropositions = self.propositionLayer.getPropositions()
        currentLayerMutexActions = self.actionLayer.getMutexActions()
        for p1 in currentLayerPropositions:
            for p2 in currentLayerPropositions:
                if p1 != p2 and \
                        Pair(p1, p2) not in self.propositionLayer.getMutexProps() and \
                        mutexPropositions(p1, p2, currentLayerMutexActions):
                    self.propositionLayer.addMutexProp(p1, p2)

    def expand(self, previousLayer):
        """
    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.   
    """
        previousPropositionLayer = previousLayer.getPropositionLayer()
        previousLayerMutexProposition = previousPropositionLayer.getMutexProps(
        )
        # doing the algorithm of adding a layer,
        self.updateActionLayer(previousPropositionLayer)
        self.updateMutexActions(previousLayerMutexProposition)
        self.updatePropositionLayer()
        self.updateMutexProposition()

    def expandWithoutMutex(self, previousLayer):
        """
    Questions 11 and 12
    You don't have to use this function
    """
        previousLayerProposition = previousLayer.getPropositionLayer()
        # self.updateActionLayer(previousLayerProposition)
        # self.updatePropositionLayer()
        "*** YOUR CODE HERE ***"