def evaluateNoInput(self): r = Runner() for i in [x for x in self.population if x.fitness is None]: i.result = r.run(i.dna) i.fitness = self.problem.fitness(i.result) self.population.sort()
def evaluateTestSet(self, testSet): r = Runner() for i in [x for x in self.population if x.fitness is None]: fitness = 0 try: for testValue in testSet: i.result = r.run(individual=i, startValue=testValue) fitness += self.problem.fitness(i.result, testValue) i.fitness = fitness except OverflowError: i.fitness = 1.7976931348623157e+308 self.population.sort()
def evaluateTestSet(self, testSet): r = Runner() for i in [x for x in self.population if x.fitness is None]: fitness = 0 try: for testValue in testSet: i.result = r.run(individual=i, startValue=testValue) self.log.debug("result {}, testValue {}".format( i.result, testValue)) fitness += self.problem.fitness(i.result, testValue) i.fitness = fitness except OverflowError: i.fitness = 1.7976931348623157e+308 self.population.sort()
# i = Individual(systemLog, ArithmeticGenome, age, "bob", dnaString=dna) # # runner = Runner() # # print runner.run(individual=i) ## Test Process An Input dna = "*2+3" # expected output is: input*2+3. So 2 -> 7, 10 -> 23 dna = ">*<" # expected output is squared (stores value to storage, retrieves storage to number, multiplies value by number dna = "+>*7<+<+<+<*3>-7-5-N" # 3n^2 + 9n -17 ??? i = Individual(systemLog, ArithmeticGenome, age, "bob", dnaString=dna) runner = Runner() print runner.run(individual=i,startValue=4971) # print runner.run(individual=i,startValue=10) ## Arbitrarily Long Dna is always executable # i = Individual(systemLog, ArithmeticGenome, age, "bob", params={"length" : 100}) # print "".join(i.dna) # # runner = Runner() # # print runner.run(individual=i)
dna = "2*N2.5" # expected output fixed value -5.0 # i = Individual(systemLog, ArithmeticGenome, age, "bob", dnaString=dna) # # runner = Runner() # # print runner.run(individual=i) ## Test Process An Input dna = "*2+3" # expected output is: input*2+3. So 2 -> 7, 10 -> 23 dna = ">*<" # expected output is squared (stores value to storage, retrieves storage to number, multiplies value by number dna = "+>*7<+<+<+<*3>-7-5-N" # 3n^2 + 9n -12 (evolved) dna = ">/+>+<-1-1" # *2+2 (evolved) dna = "F92-1O+5><" # * 2 -2 (evolved) i = Individual(systemLog, ArithmeticGenome, age, "bob", dnaString=dna) runner = Runner() print(runner.run(individual=i, startValue=0.1)) # print runner.run(individual=i,startValue=10) ## Arbitrarily Long Dna is always executable # i = Individual(systemLog, ArithmeticGenome, age, "bob", params={"length" : 100}) # print "".join(i.dna) # # runner = Runner() # # print runner.run(individual=i)