Example #1
0
    N=4;

else: 
    useRecurrent =False
    pMut = 0.6;
    pCross = 1;
    N=5
    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());
Example #2
0
mr = 25;
ii = 0;

INdim = 2;
OUTdim = 1;
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();
Example #3
0
# which setup to use?
config=1

if config == 1: # this works pretty well (approximates sum)
    useRecurrent =True
    pMut = 0.1
    pCross = 0.9;
    popsize = 3;
    maxgen = 1;
    N=2


print N
#################
ea = EA(INdim, OUTdim, N, maxgen,popsize,minw,maxw);
ea.setProbabilities(pMut,pCross);
ea.initPop();
print 'starting build'
# evolution insert here


ind = ea.getInd();
ind.printMatrix();        
net = buildExperiment(ind);
print 'build done \n\n'




Example #4
0
    print ind.getFitness().get();
    error = runExperiment(INdim,OUTdim,N,getI1,getI2,getOut,getW,t,dt);

# setup
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);
Example #5
0
    pMut = 0.6;
    pCross = 1;
    N=5
    popsize = 30;
    maxgen = 20;

else: 
    useRecurrent =False
    pMut = 0.6;
    pCross = 1;
    N=5
    popsize = 3;
    maxgen = 1;

# init EA
ea = EA(INdim, OUTdim, N, maxgen,popsize,minw,maxw);
ea.setProbabilities(pMut,pCross);
ea.initPop();

# evolution insert here
while ea.wantsEval():
    print 'gen: '+repr(ea.generation())+' actual ind is ' +repr(ea.actualOne())+ ' best so far: '+repr(ea.getBestFitness());
    print ' '

    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());
    
Example #6
0
mr = 10;
ii = 0;

# setup
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();
ind = ea.getInd();
ind.printMatrix();        

net=nef.Network('IO neuron transfer fcn test')  


# generator
# function .1 base freq, max freq 10 rad/s, and RMS of .5; 12 is a seed
generator=FunctionInput('generator',[FourierFunction(.1, 12,.3, 12),
    FourierFunction(.5, 20, .7, 112)],Units.UNK) 
net.add(generator);


# model
Example #7
0
    pCross = 0.9;
    popsize = 30;
    maxgen = 100;
    N=4

else: 
    useRecurrent =False
    pMut = 0.6;
    pCross = 1;
    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);