Пример #1
0
 def __init__(self, rightParent, leftParent):
     '''
     Constructor
     '''
     JoinNode.__init__(self, rightParent, leftParent, [])
     Memory.__init__(self)
     self._existsCount = 0
Пример #2
0
 def __init__(self, rightParent, leftParent):
     """
     Constructor
     """
     JoinNode.__init__(self, rightParent, leftParent, [])
     Memory.__init__(self)
     self._existsCount = 0
Пример #3
0
 def delete(self, notifierRemoval=None, notifierUnlinking=None):
     """
     Remove the negative join node from the network
     and delete all tokens created by this node
     """
     # destroy tokens in memory
     Memory.delete(self)
         
     # then i can call parent destructor
     JoinNode.delete(self, notifierRemoval, notifierUnlinking)
Пример #4
0
 def delete(self, notifierRemoval=None, notifierUnlinking=None):
     """
     Remove the negative join node from the network
     and delete all tokens created by this node
     """
     
     for wme in self.rightParent.items:
         wme.unlinkExistsNode(self)
     
     # destroy tokens in memory
     Memory.delete(self)
         
     # then i can call parent destructor
     JoinNode.delete(self, notifierRemoval, notifierUnlinking)
Пример #5
0
    def delete(self, notifierRemoval=None, notifierUnlinking=None):
        """
        Remove the negative join node from the network
        and delete all tokens created by this node
        """

        for wme in self.rightParent.items:
            wme.unlinkExistsNode(self)

        # destroy tokens in memory
        Memory.delete(self)

        # then i can call parent destructor
        JoinNode.delete(self, notifierRemoval, notifierUnlinking)
Пример #6
0
    def _shareNode_JoinNode(self, lastCircuitNode, alphaMemory, tests):

        # check if i can share looking at beta network first
        if lastCircuitNode is not None:

            for child in lastCircuitNode.children:

                # i can't use isinstance, child must be exactly a JoinNode
                # otherwise negative node could be shared and this is a problem
                if (child.__class__ == JoinNode
                        # is a join node
                        and child.rightParent == alphaMemory
                        # alpha memory is the same
                        and child.tests == tests):
                    # tests are the same too

                    # i can share the node
                    self.eventsManager.fire(EventsManager.E_NODE_SHARED, child)
                    return child

        else:
            # try to share node looking at the alphaMemory
            # this could allow to share dummy join nodes
            for child in alphaMemory.children:
                # i can't use isinstance, child must be exactly a JoinNode
                # otherwise negative node could be shared and this is a problem
                if (child.__class__ == JoinNode
                        # is a join node
                        and child.isLeftRoot()
                        # like the node i will create, this one is left dummy
                        and child.tests == tests):
                    # tests are the same too

                    # i can share the node
                    self.eventsManager.fire(EventsManager.E_NODE_SHARED, child)
                    return child

        # i can't share an old node
        # it's time to create a new one

        newChild = JoinNode(rightParent=alphaMemory,
                            leftParent=lastCircuitNode,
                            tests=tests)
        # link the new join to the right alpha memory
        alphaMemory.prependChild(newChild)

        if lastCircuitNode is not None:
            # link the join node to the parent
            lastCircuitNode.prependChild(newChild)
            # it's useless to update a leaf join node
            # even if it find matches
            # it has no children to propage the activation

        #myclips.logger.info("New node: %s", newChild)
        #myclips.logger.info("Right-linked node: %s to %s", newChild, alphaMemory)
        #myclips.logger.info("Left-linked node: %s to %s", newChild, lastCircuitNode)

        self.eventsManager.fire(EventsManager.E_NODE_ADDED, newChild)
        self.eventsManager.fire(EventsManager.E_NODE_LINKED, lastCircuitNode,
                                newChild, -1)
        self.eventsManager.fire(EventsManager.E_NODE_LINKED, alphaMemory,
                                newChild, 1)

        return newChild
Пример #7
0
 def __init__(self, rightParent, leftParent, tests=None):
     '''
     Constructor
     '''
     JoinNode.__init__(self, rightParent=rightParent, leftParent=leftParent, tests=tests)
     Memory.__init__(self)