예제 #1
0
 def __init__(self, parent=None, tests=None):
     '''
     Constructor
     '''
     Node.__init__(self, rightParent=parent)
     HasMemory.__init__(self, None)
     HasTests.__init__(self, tests)
예제 #2
0
 def __init__(self, parent=None, tests=None):
     '''
     Constructor
     '''
     Node.__init__(self, rightParent=parent)
     HasMemory.__init__(self, None)
     HasTests.__init__(self, tests)
예제 #3
0
    def delete(self, notifierRemoval=None, notifierUnlinking=None):
        """
        Remove the alpha-memory from the network
        """

        # before to call the Node.delete,
        # references to this alpha-memory
        # have to be removed
        # from all wme object
        # but wme.delete()
        # isn't called because a-memory
        # delete doens't mean fact retract
        for wme in self.items:
            wme.unlinkAlphaMemory(self)

        # before call the Node.delete,
        # manually remove the parent's reference
        # to this node (because alpha memory is in
        # parent.memory slot, not in children

        if not self.isRightRoot():
            if callable(notifierUnlinking):
                notifierUnlinking(self.rightParent, self)

            self.rightParent.memory = None
            if self.rightParent.isLeaf():
                self.rightParent.delete(notifierRemoval, notifierUnlinking)
            self.rightParent = None

        Node.delete(self, notifierRemoval, notifierUnlinking)
예제 #4
0
 def delete(self, notifierRemoval=None, notifierUnlinking=None):
     """
     Remove the alpha-memory from the network
     """
     
     # before to call the Node.delete,
     # references to this alpha-memory 
     # have to be removed
     # from all wme object
     # but wme.delete()
     # isn't called because a-memory
     # delete doens't mean fact retract
     for wme in self.items:
         wme.unlinkAlphaMemory(self)
         
         
     # before call the Node.delete,
     # manually remove the parent's reference
     # to this node (because alpha memory is in
     # parent.memory slot, not in children
     
     if not self.isRightRoot():
         if callable(notifierUnlinking):
             notifierUnlinking(self.rightParent, self)
         
         self.rightParent.memory = None
         if self.rightParent.isLeaf():
             self.rightParent.delete(notifierRemoval, notifierUnlinking)
         self.rightParent = None
     
     Node.delete(self, notifierRemoval, notifierUnlinking)
예제 #5
0
 def __init__(self, leftParent, rightParent, partnerCircuitLength):
     '''
     Create the new ncc node
     '''
     Node.__init__(self, rightParent=None, leftParent=leftParent)
     Memory.__init__(self)
     
     self._partner = NccPartnerNode(rightParent, partnerCircuitLength, self)
예제 #6
0
    def __init__(self, leftParent, rightParent, partnerCircuitLength):
        '''
        Create the new ncc node
        '''
        Node.__init__(self, rightParent=None, leftParent=leftParent)
        Memory.__init__(self)

        self._partner = NccPartnerNode(rightParent, partnerCircuitLength, self)
예제 #7
0
 def __init__(self, leftParent, circuitLenght, nccNode):
     '''
     Build a new NccPartner
     '''
     Node.__init__(self, leftParent=leftParent)
     
     self._circuitLength = circuitLenght
     self._nccNode = nccNode
     self._buffer = []
예제 #8
0
    def __init__(self, leftParent, circuitLenght, nccNode):
        '''
        Build a new NccPartner
        '''
        Node.__init__(self, leftParent=leftParent)

        self._circuitLength = circuitLenght
        self._nccNode = nccNode
        self._buffer = []
예제 #9
0
 def delete(self, notifierRemoval=None, notifierUnlinking=None):
     if self.isMain:
         for linkedNode in self._linkedPNodes:
             linkedNode.delete(notifierRemoval, notifierUnlinking)
             
         self._linkedPNodes = []
         
     Memory.delete(self)
     Node.delete(self, notifierRemoval, notifierUnlinking)
예제 #10
0
 def delete(self, notifierRemoval=None, notifierUnlinking=None):
     """
     Remove the beta-memory from the network
     """
     # first delete all tokens
     Memory.delete(self)
         
     # then i can call parent destructor
     Node.delete(self, notifierRemoval, notifierUnlinking)
예제 #11
0
    def delete(self, notifierRemoval=None, notifierUnlinking=None):
        """
        Remove the beta-memory from the network
        """
        # first delete all tokens
        Memory.delete(self)

        # then i can call parent destructor
        Node.delete(self, notifierRemoval, notifierUnlinking)
예제 #12
0
 def delete(self, notifierRemoval=None, notifierUnlinking=None):
     """
     Remove this node and the partner from the network
     """
     # notify unlink between ncc and partner
     #EventManager.trigger(EventManager.E_NODE_UNLINKED, self.get_partner(), self)
     # then destroy the partner
     self.partner.delete(notifierRemoval, notifierUnlinking)
     # and last destroy this node itself
     Memory.delete(self)
     Node.delete(self, notifierRemoval, notifierUnlinking)
예제 #13
0
 def delete(self, notifierRemoval=None, notifierUnlinking=None):
     """
     Remove this node and the partner from the network
     """
     # notify unlink between ncc and partner
     #EventManager.trigger(EventManager.E_NODE_UNLINKED, self.get_partner(), self)
     # then destroy the partner
     self.partner.delete(notifierRemoval, notifierUnlinking)
     # and last destroy this node itself
     Memory.delete(self)
     Node.delete(self, notifierRemoval, notifierUnlinking)
예제 #14
0
    def delete(self, notifierRemoval=None, notifierUnlinking=None):
        """
        Delete all token in the results buffer
        and then remove the node from the network.
        """
        while len(self._buffer) > 0:
            # i use the pop:
            # token doesn't have
            # link to results buffer
            # so i must force the ref removal
            # from it
            self._buffer.pop().delete()

        Node.delete(self, notifierRemoval, notifierUnlinking)
예제 #15
0
 def delete(self, notifierRemoval=None, notifierUnlinking=None):
     """
     Delete all token in the results buffer
     and then remove the node from the network.
     """
     while len(self._buffer) > 0:
         # i use the pop:
         # token doesn't have
         # link to results buffer
         # so i must force the ref removal
         # from it
         self._buffer.pop().delete()
         
     Node.delete(self, notifierRemoval, notifierUnlinking)
예제 #16
0
    def __init__(self, ruleName, leftParent, network, orClauseCount=None, rhs=None, properties=None, moduleName=None, variables=None):
        '''
        Constructor
        '''
        self._ruleName = ruleName + (("~"+str(orClauseCount)) if orClauseCount is not None else "")
        self._isMain = (orClauseCount is None)
        self._network = network
        self._rhs = rhs
        self._linkedPNodes = []
        self._properties = {"salience": 0, "auto-focus": False} if properties is None or not isinstance(properties, dict) else properties
        self._moduleName = moduleName if moduleName is not None else network.modulesManager.currentScope.moduleName
        self._variables = variables if isinstance(variables, dict) else {}

        Node.__init__(self, leftParent=leftParent)
        Memory.__init__(self)
예제 #17
0
 def __init__(self, parent=None):
     '''
     Constructor
     '''
     Node.__init__(self, rightParent=parent, leftParent=None)
     Memory.__init__(self)
예제 #18
0
 def isLeaf(self):
     return not self.hasMemory() and Node.isLeaf(self)
예제 #19
0
 def __init__(self, rightParent=None, leftParent=None, tests=None):
     '''
     Constructor
     '''
     Node.__init__(self, rightParent, leftParent)
     HasJoinTests.__init__(self, tests)
예제 #20
0
 def __init__(self, leftParent=None, tests=None):
     '''
     Constructor
     '''
     Node.__init__(self, leftParent=leftParent)
     HasJoinTests.__init__(self, tests)
예제 #21
0
 def __init__(self, network):
     '''
     Constructor
     '''
     Node.__init__(self)
     self._network = network
예제 #22
0
 def isLeaf(self):
     return not self.hasMemory() and Node.isLeaf(self)
예제 #23
0
 def __init__(self, network):
     '''
     Constructor
     '''
     Node.__init__(self)
     self._network = network
예제 #24
0
 def __init__(self, parent=None):
     '''
     Constructor
     '''
     Node.__init__(self, rightParent=parent, leftParent=None)
     Memory.__init__(self)