Ejemplo n.º 1
0
 def _interference(self, actionA, actionB):
     """ Return True if the effects of either action negate the preconditions of the other 
     
     See Also
     --------
     layers.ActionNode
     """
     # TODO: implement this function
     #raise NotImplementedError
     for x in actionA.effects:
         for y in actionB.preconditions:
             #check to see if action A effects negates actionB preconditions
             if (x.op =='~' and y.op!='~'):
                 y_neg = Expr('~',y);
                 if y_neg.__eq__(x):
                     return True;
             if (y.op =='~' and x.op!='~'):
                 x_neg = Expr('~',x);
                 if x_neg.__eq__(y):
                     return True;
         
     for x in actionB.effects:
         for y in actionA.preconditions:
             #check to see if action B effects negates actionA preconditions
             if (x.op =='~' and y.op!='~'):
                 y_neg = Expr('~',y);
                 if y_neg.__eq__(x):
                     return True;
             if (y.op =='~' and x.op!='~'):
                 x_neg = Expr('~',x);
                 if x_neg.__eq__(y):
                     return True;
         
     return False;    
Ejemplo n.º 2
0
    def _competing_needs(self, actionA, actionB):
        """ Return True if the preconditions of the actions are all pairwise mutex in the parent layer 
        
        See Also
        --------
        layers.ActionNode
        layers.BaseLayer.parent_layer
        """
        # TODO: implement this function
        # raise NotImplementedError
        # print(self.parent_layer.is_mutex(actionA,actionB))
        # print(type(self.parent_layer.children))
        # print(self.parent_layer.children)
        for x in actionA.preconditions:
            for y in actionB.preconditions:
                # print("-----",type(x),"->",len(x.args),"->",x.args)
                #print(type(x),"->",x," :: ",type(y),"->",y)
                #print(type(x),"->",(x.__invert__)," :: ",type(y),"->",(y) )
                if (x.op == '~' and y.op != '~'):
                    y_neg = Expr('~', y)
                    if y_neg.__eq__(x):
                        #print(x, " = ", y_neg);
                        return True
                if (y.op == '~' and x.op != '~'):
                    x_neg = Expr('~', x)
                    if x_neg.__eq__(y):
                        #print(y, " = ", x_neg);
                        return True

        return False
Ejemplo n.º 3
0
    def _interference(self, actionA, actionB):
        """ Return True if the effects of either action negate the preconditions of the other 
        
        See Also
        --------
        layers.ActionNode
        """
        # TODO: implement this function
        for x in actionA.effects:
            for y in actionB.preconditions:
                if x.op == "~" and y.op != "~":
                    y_neg = Expr("~", y)
                    if y_neg.__eq__(x):
                        return True
                if y.op == "~" and x.op != "~":
                    x_neg = Expr("~", x)
                    if x_neg.__eq__(y):
                        return True

        for x in actionB.effects:
            for y in actionA.preconditions:
                if x.op == "~" and y.op != "~":
                    y_neg = Expr("~", y)
                    if y_neg.__eq__(x):
                        return True
                if y.op == "~" and x.op != "~":
                    x_neg = Expr("~", x)
                    if x_neg.__eq__(y):
                        return True

        return False
Ejemplo n.º 4
0
    def _inconsistent_effects(self, actionA, actionB):
        """ Return True if an effect of one action negates an effect of the other

        See Also
        --------
        layers.ActionNode
        """
        #------ TODO: implement this function
        '''
        for x in actionA.effects:
            if x in actionB.effects:
                #print("ypu1 -> ",x," :: ", actionB.effects)
                #return True;
                print("-")
                
        for x in actionB.effects:
            if x in actionA.effects:
                #print("ypu2 -> ",x," :: ", actionA.effects)
                return True;    
        '''

        # print("--------",type(actionA.effects)) = <class 'frozenset'>
        # print("--------",type(actionA)) = <class 'layer.actionNode'>

        for x in actionA.effects:
            # print("--------",type(x in actionA.effect)) = <class 'aimacode.utils.expr'>
            # print("--------",type(x.op)) = <class 'str'>
            # print("--------",type(x.args)) = <class 'tuple'>
            for y in actionB.effects:
                #print("ypu3------> ",x," :: ", actionB.effects)
                #print("x= ",x)
                #print("x= ",expr(x))
                #print("x.op",x.op )
                #if(x.op!='~'):
                #    print("x neg", Expr('~',x))
                #print("x.arg---",x.args )
                #print("x.arg",x.args[0] )
                #print("y= ",y)
                #print("y.op",y.op )
                #print("y.arg",y.args )'''
                if (x.op == '~' and y.op != '~'):
                    #print("ypu")
                    #print("x= ",x)
                    #print("y= ",y)
                    y_neg = Expr('~', y)
                    #print("~y= ",y_neg)
                    if y_neg.__eq__(x):
                        #print(x, " = ", y_neg)
                        return True
                if (y.op == '~' and x.op != '~'):
                    x_neg = Expr('~', x)
                    if x_neg.__eq__(y):
                        #print(y, " = ", x_neg)
                        return True

        return False
Ejemplo n.º 5
0
    def _negation(self, literalA, literalB):
        """ Return True if two literals are negations of each other """
        
        if literalA.op == '~' and literalB.op!='~':
            temp_neg = Expr('~',literalB);
            if temp_neg.__eq__(literalA):
                return True
        if literalA.op != '~' and literalB.op=='~':
            temp_neg = Expr('~',literalA);
            if temp_neg.__eq__(literalB):
                return True            

        return False
Ejemplo n.º 6
0
    def _negation(self, literalA, literalB):
        """ Return True if two literals are negations of each other """
        # TODO: implement this function
        if literalA.op == "~" and literalB.op != "~":
            temp_neg = Expr("~", literalB)
            if temp_neg.__eq__(literalA):
                return True
        if literalA.op != "~" and literalB.op == "~":
            temp_neg = Expr("~", literalA)
            if temp_neg.__eq__(literalB):
                return True

        return False
Ejemplo n.º 7
0
    def _inconsistent_effects(self, actionA, actionB):
        """ Return True if an effect of one action negates an effect of the other

        See Also
        --------
        layers.ActionNode
        """
        # TODO: implement this function
        for x in actionA.effects:
            for y in actionB.effects:
                if x.op == "~" and y.op != "~":
                    y_neg = Expr("~", y)
                    if y_neg.__eq__(x):
                        return True
                if y.op == "~" and x.op != "~":
                    x_neg = Expr("~", x)
                    if x_neg.__eq__(y):
                        return True
        return False
Ejemplo n.º 8
0
    def _negation(self, literalA, literalB):
        """ Return True if two literals are negations of each other """
        # TODO: implement this function
        # raise NotImplementedError
        #print("----")
        #print("literal A = ",literalA," : args = ",literalA.args," : op = ", literalA.op)
        #print("literal B = ",literalB," : args = ",literalB.args," : op = ", literalB.op)

        if literalA.op == '~' and literalB.op != '~':
            temp_neg = Expr('~', literalB)
            #print("ned literalB",temp_neg);
            if temp_neg.__eq__(literalA):
                return True
        if literalA.op != '~' and literalB.op == '~':
            temp_neg = Expr('~', literalA)
            #print("ned literalA",temp_neg);
            if temp_neg.__eq__(literalB):
                return True

        return False
Ejemplo n.º 9
0
    def _inconsistent_effects(self, actionA, actionB):
        """ Return True if an effect of one action negates an effect of the other

        See Also
        --------
        layers.ActionNode
        """
        #------ TODO: implement this function
        
        for x in actionA.effects:
            for y in actionB.effects:
                #check to see if actionA and action B are opposites...
                    if (x.op =='~' and y.op!='~'):
                        y_neg = Expr('~',y)
                        if y_neg.__eq__(x):
                            return True;
                    if (y.op =='~' and x.op!='~'):
                        x_neg = Expr('~',x)
                        if x_neg.__eq__(y):
                            return True;
                
        return False;    
Ejemplo n.º 10
0
    def _interference(self, actionA, actionB):
        """ Return True if the effects of either action negate the preconditions of the other 
        
        See Also
        --------
        layers.ActionNode
        """
        # TODO: implement this function
        #raise NotImplementedError
        for x in actionA.effects:
            for y in actionB.preconditions:
                if (x.op == '~' and y.op != '~'):
                    y_neg = Expr('~', y)
                    if y_neg.__eq__(x):
                        #print(x, " = ", y_neg);
                        return True
                if (y.op == '~' and x.op != '~'):
                    x_neg = Expr('~', x)
                    if x_neg.__eq__(y):
                        #print(y, " = ", x_neg);
                        return True

        for x in actionB.effects:
            for y in actionA.preconditions:
                if (x.op == '~' and y.op != '~'):
                    y_neg = Expr('~', y)
                    if y_neg.__eq__(x):
                        #print(x, " = ", y_neg);
                        return True
                if (y.op == '~' and x.op != '~'):
                    x_neg = Expr('~', x)
                    if x_neg.__eq__(y):
                        #print(y, " = ", x_neg);
                        return True

        return False