Beispiel #1
0
    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)
Beispiel #2
0
  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)
Beispiel #3
0
  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 ***"

    props = dict()

    for action in currentLayerActions:
      for pro in action.getAdd():
        if pro.getName() not in props:
          props[pro.getName()] = [action]
        else:
          props[pro.getName()] = props[pro.getName()] + [action]

    for pro in props:
      prop = Proposition(pro)
      prop.setProducers(props[pro])
      self.propositionLayer.addProposition(prop)