* indentations + whitespace cleanup
This commit is contained in:
parent
8457e39efe
commit
56c6edab04
285 changed files with 6068 additions and 6223 deletions
|
|
@ -2,43 +2,44 @@ from maxone import *
|
|||
import unittest
|
||||
|
||||
class TestSGA(unittest.TestCase):
|
||||
|
||||
def dotestSGA(self, evaluate):
|
||||
init = Init(20)
|
||||
mutate = Mutate()
|
||||
xover = Crossover()
|
||||
init = Init(20)
|
||||
mutate = Mutate()
|
||||
xover = Crossover()
|
||||
|
||||
pop = eoPop(50, init)
|
||||
for indy in pop: evaluate(indy)
|
||||
pop = eoPop(50, init)
|
||||
for indy in pop: evaluate(indy)
|
||||
|
||||
select = eoDetTournamentSelect(3);
|
||||
cont1 = eoGenContinue(20);
|
||||
|
||||
cont = eoCheckPoint(cont1)
|
||||
|
||||
mon = eoGnuplot1DMonitor()
|
||||
|
||||
avg = eoAverageStat()
|
||||
bst = eoBestFitnessStat()
|
||||
mon.add(avg)
|
||||
mon.add(bst)
|
||||
|
||||
# add it to the checkpoint
|
||||
cont.add(avg)
|
||||
#cont.add(mon)
|
||||
cont.add(bst)
|
||||
|
||||
sga = eoSGA(select, xover, 0.6, mutate, 0.4, evaluate, cont);
|
||||
select = eoDetTournamentSelect(3);
|
||||
cont1 = eoGenContinue(20);
|
||||
|
||||
sga(pop)
|
||||
cont = eoCheckPoint(cont1)
|
||||
|
||||
mon = eoGnuplot1DMonitor()
|
||||
|
||||
avg = eoAverageStat()
|
||||
bst = eoBestFitnessStat()
|
||||
mon.add(avg)
|
||||
mon.add(bst)
|
||||
|
||||
# add it to the checkpoint
|
||||
cont.add(avg)
|
||||
#cont.add(mon)
|
||||
cont.add(bst)
|
||||
|
||||
sga = eoSGA(select, xover, 0.6, mutate, 0.4, evaluate, cont);
|
||||
|
||||
sga(pop)
|
||||
|
||||
print pop.best()
|
||||
|
||||
print pop.best()
|
||||
def testSGA_Max(self):
|
||||
evaluate = EvalFunc()
|
||||
self.dotestSGA(evaluate)
|
||||
evaluate = EvalFunc()
|
||||
self.dotestSGA(evaluate)
|
||||
|
||||
def testSGA_Min(self):
|
||||
evaluate = MinEvalFunc()
|
||||
self.dotestSGA(evaluate)
|
||||
evaluate = MinEvalFunc()
|
||||
self.dotestSGA(evaluate)
|
||||
|
||||
if __name__=='__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Reference in a new issue