コード例 #1
0
ファイル: PlanGraph.py プロジェクト: crystalhaohua0408/hw
    def expand(self, previousLevel, allProps, allActions
               ):  #you can change the params the function takes if you like
        Pk = PropositionLayer()
        Ak = ActionLayer()

        for action in allActions:
            pre = action.getPre()
            if not (False in [
                (item1
                 in previousLevel.getPropositionLayer().getPropositions())
                    for item1 in pre
            ]):
                if (not self.are_all_Mutex(
                        pre, previousLevel.getPropositionLayer())):
                    Ak.addAction(action)

        for (action1, action2) in combinations(Ak.getActions(), 2):
            if action1 != action2:
                if previousLevel.mutexActions(
                        action1, action2,
                        previousLevel.getPropositionLayer().getMutexProps()):
                    Ak.addMutexActions(action1, action2)

        for prop in allProps:
            for action in Ak.getActions():
                if action.isPosEffect(prop):
                    Pk.addProposition(prop)

        for (prop, prop2) in combinations(Pk.getPropositions(), 2):
            if (prop != prop2) and (self.mutexPropositions(
                    prop, prop2, Ak.getMutexActions())):
                Pk.addMutexProp(prop, prop2)

        self.setPropositionLayer(Pk)
        self.setActionLayer(Ak)
コード例 #2
0
 def __init__(self, level):
     '''
     Constructor
     '''
     self.level = level
     self.actionLayer = ActionLayer()
     self.propositionLayer = PropositionLayer()
コード例 #3
0
ファイル: PlanGraph.py プロジェクト: crystalhaohua0408/hw
 def __init__(self, level, independentActions):
     '''
     Constructor
     '''
     self.level = level
     self.independentActions = independentActions  # a list of the independent actions (this would be the same at each level)
     self.actionLayer = ActionLayer()
     self.propositionLayer = PropositionLayer()
コード例 #4
0
    def expand(self, previousLevel, allProps, allActions
               ):  # you can change the params the function takes if you like
        previousPropositionLayer = previousLevel.getPropositionLayer()
        newActionLayer = ActionLayer()

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

        newPropositionLayer = PropositionLayer()
        for prop in allProps:
            if newActionLayer.effectExists(prop):
                newPropositionLayer.addProposition(prop)
        # set new proposition layer
        self.setPropositionLayer(newPropositionLayer)
コード例 #5
0
ファイル: PlanGraph.py プロジェクト: sbalanovich/cs182asst4
    def expand(self, previousLevel, allProps, allActions
               ):  # you can change the params the function takes if you like
        previousPropositionLayer = previousLevel.getPropositionLayer()
        newActionLayer = ActionLayer()

        for action in allActions:
            if previousPropositionLayer.allPrecondsInLayer(action):
                newActionLayer.addAction(action)
        # add mutex actions
        for action1 in newActionLayer.getActions():
            for action2 in newActionLayer.getActions():
                actionPair = Pair(action1, action2)
                if action1 != action2 and self.mutexActions(
                        action1, action2,
                        previousPropositionLayer.getMutexProps()
                ) and actionPair not in newActionLayer.getMutexActions():
                    newActionLayer.addMutexActions(action1, action2)

        self.actionLayer = newActionLayer

        newPropositionLayer = PropositionLayer()
        for prop in allProps:
            if newActionLayer.effectExists(prop):
                newPropositionLayer.addProposition(prop)

        # add mutex propositions
        for prop1 in newPropositionLayer.getPropositions():
            for prop2 in newPropositionLayer.getPropositions():
                propPair = Pair(prop1, prop2)
                if prop1 != prop2 and self.mutexPropositions(
                        prop1, prop2, newActionLayer.getMutexActions()
                ) and propPair not in newPropositionLayer.getMutexProps():
                    newPropositionLayer.addMutexProp(prop1, prop2)

        # set new proposition layer
        self.setPropositionLayer(newPropositionLayer)