Exemple #1
0
def getTree():
    dich1 = statements.get_negation(statements.get_moreThan(statements.get_statement(statements.op_takeValue,['MinIntensity']),0.7))
    dich11 = statements.get_negation(statements.get_moreThan(statements.get_statement(statements.op_takeValue,['MinIntensity']),0.35))
    
    tree = treeNode.treeNode([],[])
    tree.dichotomy = dich1
    tree.isTerminal = False
    tree.childNegative = treeNode.treeNode([],[])
    tree.childNegative.result = [False,False]
    tree.childPositive = treeNode.treeNode([],[])
    tree.childPositive.dichotomy = dich11
    tree.childPositive.isTerminal = False
    tree.childPositive.childNegative = treeNode.treeNode([],[])
    tree.childPositive.childNegative.result = [True,False]
    tree.childPositive.childPositive = treeNode.treeNode([],[])
    tree.childPositive.childPositive.result = [True,True]

    return tree
Exemple #2
0
 def updateChromo(self, chromo):
     '''propagates new states to the system and it's trees'''
     #why: samples addition and updates are done in parallel (in NeuroCar proj at least), so not doint this
     #may result in losing a bool name to update(crash almost inevitable) if it was added while this function was called.
     
     for name in self.boolNames:
         state=statements.get_statement(statements.op_takeValue,[name])
         if state not in chromo.keyStatements:
             treeAddNewKeyState(chromo.tree,state)
             chromo.keyStatements.add(state)
Exemple #3
0
 def updateSystem(self, system):
     '''propagates new states to the system and it's trees'''
     #why: samples addition and updates are done in parallel (in NeuroCar proj at least), so not doint this
     #may result in losing a bool name to update(crash almost inevitable) if it was added while this function was called.
     
     for name in self.boolNames:
         if name not in system.keyParams:
             state=statements.get_statement(statements.op_takeValue,[name])
             systemAddNewKeyState(system,state)
             system.keyParams.append(name)
Exemple #4
0
 def addValue(self,val,system = None):
     if val in self.values:
         raise ValueError( 'Existent value')
     self.item[len(self.values)] = val
     self.code[val] =len(self.values)
     self.values.append(val)
     if roundup(log(len(self.values),2)) > self.numVars:
         self.numVars +=1
         self.boolNames.append(self.name+str(len(self.boolNames)))
         if system!=None:
             state=statements.get_statement(statements.op_takeValue,[self.boolNames[self.numVars -1]])
             system.keyStatements.insert(0,state)
             propagateNewKeyState(system.tree,state)
             for sample in system.samples:
                 setattr(sample,self.boolNames[-1],0)