popsize = 4; maxgen = 10; numRuns=10; for expNo in range(numRuns): print '----------------------- experiment number %d'%expNo # init EA ea = EA(INdim, OUTdim, N, maxgen,popsize,minw,maxw); ea.setProbabilities(pMut,pCross); ea.initPop(); 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()); ind = ea.getInd(); #ind.printMatrix(); error = evalInd(ind); ind.getFitness().setError(error); print 'Ind: '+repr(ea.actualOne())+' Error is: '+repr(error) +' fitness is: '+repr(ind.getFitness().get()); print ea.getActualWeights(); # evaluated the last individual in the generatio? write stats if (ea.actualOne() == (popsize-1)): print 'check: '+repr(ea.generation()) fit = ea.getBestInd().getFitness().get();
N = 1; minw = 0; maxw = 0.3; popsize = 1; maxgen = 0; t = 5; dt = 0.001; # init EA ea = EA(INdim, OUTdim, N, maxgen,popsize,minw,maxw); ea.initPop(); # evolution insert here while ea.wantsEval(): print 'gen: '+repr(ea.generation())+' actual ind is ' +repr(ea.actualOne()) ind = ea.getInd(); ind.printMatrix(); error = evalInd(ind); #error = 0; print 'Ind: '+repr(ea.actualOne())+' Error is: '+repr(error) +' fitness is: '+repr(ind.getFitness().get()); # poc++ and check end of ea ea.nextIndividual(); # load the best one found ind = ea.getIndNo(ea.getBest()); net = buildExperiment(ind); print 'best fitness is:'
INdim = 2; OUTdim = 1; N = 15; minw = -1; maxw = 1; popsize = 5; maxgen = 1; t = 5; dt = 0.001; ea = EA(INdim, OUTdim, N, maxgen,popsize,minw,maxw); ea.initPop(); while ea.wantsEval(): print ea.actualOne(); ind = ea.getInd(); ind.printMatrix(); # pass weights as python methods def getI1(w): w = ind.getMatrix().getInMatrixNo(0); return w; def getI2(w): w = ind.getMatrix().getInMatrixNo(1); return w; def getOut(w): w = ind.getMatrix().getOutMatrixNo(0);
INdim = 2 OUTdim = 1 N = 5 minw = -1 maxw = 1 popsize = 5 maxgen = 1 t = 5 dt = 0.001 ea = EA(INdim, OUTdim, N, maxgen, popsize, minw, maxw) ea.initPop() while ea.wantsEval(): print ea.actualOne() ind = ea.getInd() ind.printMatrix() # pass weights as python methods def getI1(w): w = ind.getMatrix().get2DInMatrixNo(0) return w def getI2(w): w = ind.getMatrix().get2DInMatrixNo(1) return w def getOut(w): w = ind.getMatrix().get2DOutMatrixNo(0)
N = 1; minw = -1; maxw = 1; popsize = 1; maxgen = 1; t = 5; dt = 0.001; # init EA ea = EA(INdim, OUTdim, N, maxgen,popsize,minw,maxw); ea.initPop(); # evolution insert here while ea.wantsEval(): print 'actual is ' +repr(ea.actualOne()) ind = ea.getInd(); ind.printMatrix(); error = evalInd(ind); print 'Ind: '+repr(ea.actualOne())+' Error is: '+repr(error) +' fitness is: '+repr(ind.getFitness().get()); # poc++ and check end of ea ea.nextIndividual(); # load the best one found ind = ea.getIndNo(ea.getBest()); net = buildExperiment(ind); print 'best fitness is:' print ind.getFitness().get();
maxgen = 5 # init EA ea = EA(INdim, OUTdim, N, maxgen, popsize, minw, maxw) ea.setProbabilities(pMut, pCross) ea.initPop() 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()) ind = ea.getInd() #ind.printMatrix(); error = evalInd(ind) ind.getFitness().setError(error) print 'Ind: ' + repr( ea.actualOne()) + ' Error is: ' + repr(error) + ' fitness is: ' + repr( ind.getFitness().get()) # print ea.getActualWeights(); # evaluated the last individual in the generatio? write stats
N=5 popsize = 4; maxgen = 5; # init EA ea = EA(INdim, OUTdim, N, maxgen,popsize,minw,maxw); ea.setProbabilities(pMut,pCross); ea.initPop(); 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()); ind = ea.getInd(); #ind.printMatrix(); error = evalInd(ind); ind.getFitness().setError(error); print 'Ind: '+repr(ea.actualOne())+' Error is: '+repr(error) +' fitness is: '+repr(ind.getFitness().get()); # print ea.getActualWeights(); # evaluated the last individual in the generatio? write stats if (ea.actualOne() == (popsize-1)): print 'check: '+repr(ea.generation()) fit = ea.getBestInd().getFitness().get();