t=2 pMut = 0.3 pCross = 0.9; popsize = 50; maxgen = 100; if config == 3: t=2 pMut = 0.3 pCross = 0.9; popsize = 30; maxgen = 100; simName = util.randomString(20); net=nef.Network('Vivae - Turning controller for agent') net.add_to_nengo() ea = EA(maxgen,popsize,minw,maxw,genomeLen); ea.setProbabilities(pMut,pCross); ea.initPop(); simulator = buildExperiment(net,wa,wb,wc,visibility=False); vivae = simulator.getControls(); expNo = round(1000000*random.random(),0); # generate some number for text file data print expNo f = open('data/tmp/ea_%d.txt'%expNo, 'w'); sx = Saver('ea_%d_agents.txt'%expNo); # saves best agent from actual generation during the evolution into a file # evolution insert here while ea.wantsEval(): print 'Gen: '+repr(ea.generation())+'/'+repr(maxgen)+' actual ind is ' +repr(ea.actualOne())+'/'+repr(popsize)+' best so far: '+repr(ea.getBestFitness()); ind = ea.getInd();
if config == 1: # this works pretty well (approximates sum) pMut = 0.1 pCross = 0.9 popsize = 3 maxgen = 1 if config == 2: pMut = 0.1 pCross = 0.9 popsize = 3 maxgen = 2 # simName = util.randomString(20); simName = "".join(random.choice(string.ascii_uppercase) for i in range(20)) net = nef.Network("Vivae - Turning controller for agent") net.add_to_nengo() ea = EA(maxgen, popsize, minw, maxw, genomeLen) ea.setProbabilities(pMut, pCross) ea.initPop() simulator = buildExperiment(net, wa, wb, wc) print "starting build" expNo = round(1000000 * random.random(), 0) # generate some number for text file data print expNo f = open("data/ea_%d.txt" % expNo, "w") # evolution insert here while ea.wantsEval(): print "Gen: " + repr(ea.generation()) + "/" + repr(maxgen) + " actual ind is " + repr(ea.actualOne()) + "/" + repr( popsize ) + " best so far: " + repr(ea.getBestFitness())
if config == 2: t = 2 pMut = 0.3 pCross = 0.9 popsize = 50 maxgen = 100 if config == 3: t = 2 pMut = 0.4 pCross = 0.9 popsize = 20 maxgen = 100 simName = util.randomString(20) net = nef.Network('Vivae - Turning controller for agent') net.add_to_nengo() ea = EA(maxgen, popsize, minw, maxw, genomeLen) ea.setProbabilities(pMut, pCross) ea.initPop() simulator = buildExperiment(net, wa, wb, wc, visibility=False) vivae = simulator.getControls() expNo = round(1000000 * random.random(), 0) # generate some number for text file data print expNo f = open('data/tmp/ea_%d.txt' % expNo, 'w') sx = Saver('ea_%d_agents.txt' % expNo) # saves best agent from actual generation during the evolution into a file # evolution insert here while ea.wantsEval(): print 'Gen: ' + repr( ea.generation()) + '/' + repr(maxgen) + ' actual ind is ' + repr(
genomeLen = 29; # which setup to use? config=1 if config == 1: # this works pretty well (approximates sum) pMut = 0.1 pCross = 0.9; popsize = 3; maxgen = 1; if config == 2: pMut = 0.1 pCross = 0.9; popsize = 50; maxgen = 150; ea = EA(maxgen,popsize,minw,maxw,genomeLen); ea.setProbabilities(pMut,pCross); ea.initPop(); print 'starting build' #expNo = round(1000000*random.random(),0); # generate some number for text file data #print expNo #f = open('data/ea_%d.txt'%expNo, 'w'); # load the best one found #ind = ea.getIndNo(ea.getBest()); #net = buildExperiment(ind); #print 'best fitness is:' #print ind.getFitness().get(); #print 'build done writing matrix to file named: \n\n'