def postInitialCodelets(self): for name in self.initialCodeletNames: for _ in range(0, workspaceFormulas.numberOfObjects()): codelet = Codelet(name, 1, self.codeletsRun) self.post(codelet) codelet2 = Codelet(name, 1, self.codeletsRun) self.post(codelet2)
def newCodelet(self, name, oldCodelet, strength, arguments=None): logging.debug('Posting new codelet called %s', name) urgency = getUrgencyBin(strength) newCodelet = Codelet(name, urgency, self.codeletsRun) if arguments: newCodelet.arguments = [arguments] else: newCodelet.arguments = oldCodelet.arguments newCodelet.pressure = oldCodelet.pressure self.tryRun(newCodelet)
def newCodelet(self, name, oldCodelet, strength, arguments=None): #logging.debug('Posting new codelet called %s' % name) urgency = getUrgencyBin(strength) newCodelet = Codelet(name, urgency, self.codeletsRun) if arguments: newCodelet.arguments = [arguments] else: newCodelet.arguments = oldCodelet.arguments newCodelet.pressure = oldCodelet.pressure self.tryRun(newCodelet)
def postInitialCodelets(self): #logging.debug('Posting initial codelets') #logging.debug('Number of inital codelets: %d' % len(self.initialCodeletNames)) #logging.debug('Number of workspaceObjects: %d' % workspace.numberOfObjects()) for name in self.initialCodeletNames: for unused in range(0, workspaceFormulas.numberOfObjects()): codelet = Codelet(name, 1, self.codeletsRun) self.post(codelet) codelet2 = Codelet(name, 1, self.codeletsRun) self.post(codelet2)
def __postBottomUpCodelets(self, codeletName): probability = workspaceFormulas.probabilityOfPosting(codeletName) howMany = workspaceFormulas.howManyToPost(codeletName) if self.speedUpBonds: if 'bond' in codeletName or 'group' in codeletName: howMany *= 3 urgency = 3 if codeletName == 'breaker': urgency = 1 if formulas.Temperature < 25.0 and 'translator' in codeletName: urgency = 5 for _ in range(0, howMany): if random.random() < probability: codelet = Codelet(codeletName, urgency, self.codeletsRun) self.post(codelet)
def postTopDownCodelets(self): for node in slipnet.slipnodes: #logging.info('Trying slipnode: %s' % node.get_name()) if node.activation != 100.0: continue #logging.info('using slipnode: %s' % node.get_name()) for codeletName in node.codelets: probability = workspaceFormulas.probabilityOfPosting( codeletName) howMany = workspaceFormulas.howManyToPost(codeletName) for _ in range(0, howMany): if random.random() >= probability: continue urgency = getUrgencyBin(node.activation * node.conceptualDepth / 100.0) codelet = Codelet(codeletName, urgency, self.codeletsRun) codelet.arguments += [node] logging.info('Post top down: %s, with urgency: %d', codelet.name, urgency) self.post(codelet)
def postTopDownCodelets(self): for node in slipnet.slipnodes: #logging.info('Trying slipnode: %s' % node.get_name()) if node.activation == 100.0: #logging.info('using slipnode: %s' % node.get_name()) for codeletName in node.codelets: probability = workspaceFormulas.probabilityOfPosting( codeletName) howMany = workspaceFormulas.howManyToPost(codeletName) #print '%s:%d' % (codeletName,howMany) for unused in range(0, howMany): if random.random() < probability: urgency = self.getUrgencyBin( node.activation * node.conceptualDepth / 100.0) codelet = Codelet(codeletName, urgency, self.codeletsRun) codelet.arguments += [node] logging.info( 'Post top down: %s, with urgency: %d' % (codelet.name, urgency)) #logging.info("From slipnode %s, activation: %s, depth: %s" %(node.get_name(),node.activation,node.conceptualDepth) ) self.post(codelet)