SHOULD_WRITE = False    # log data each step to file?
FOLDER = 'generated-data/TEST_ea_data'		# make this folder under the simulator-ui
EXP_NAME ='test'         # filename to write

###################################### setup the EA

genomelen = 14           # alpha, gamma, lambda
popSize = 50
maxGens = 80
pMut = 0.05             # probability of mutating each gene
stDev = 1               # standard deviation of applied gaussian to a gene
pCross = 0.8            # probability of crossing two selected inds
minw = 0
maxw = 1                # range of all parameters

ea = RealVectorEA(genomelen, False, maxGens, popSize, minw, maxw);
ea.mutate.setStdev(stDev);
ea.setProbabilities(pMut, pCross);

net=nef.Network('EA - based RL Single R')
net.add_to_nengo()
# build the model with default values
modelA = addModel(net, 'modelA') 
global rl
rl = modelA[0]
global mo
mo = modelA[2]

############################################################################### genome = [tstates, trr, timportance, tsi]
target = [1,0,0,1, 1,0,0,0,0,0, 0,1, 0,0] # hand-designed optimal solution
Example #2
0
# dt = 0.001

#runs = 5    # TODO
base = 'ea_params_'

###################################### set the EA parameters
genomelen = 3  # alpha, gamma, lambda
popSize = 3
maxGens = 50
pMut = 0.05  # probability of mutating each gene
stDev = 1  # standard deviation of applied gaussian to a gene
pCross = 0.8  # probability of crossing two selected inds
minw = 0
maxw = 1  # range of all parameters

ea = RealVectorEA(genomelen, False, maxGens, popSize, minw, maxw)
ea.mutate.setStdev(stDev)
ea.setProbabilities(pMut, pCross)

prevgen = 0

filename = 'prosperities.txt'

# now run the EA, store the course of the prosperity (per time step) only for the first one (best one)
while (ea.wantsEval()):

    if (prevgen != ea.generation()):
        prevgen = ea.generation()
        f = file(filename, 'a+')
        f.write('%1.1f %1.6f %s\n' %
                ((prevgen - 1), ea.getBestInd().getFitness().getValue(),
Example #3
0
# dt = 0.001

#runs = 5    # TODO
base = 'ea_params_'

###################################### set the EA parameters
genomelen = 3           # alpha, gamma, lambda
popSize = 3
maxGens = 50   
pMut = 0.05             # probability of mutating each gene
stDev = 1               # standard deviation of applied gaussian to a gene
pCross = 0.8            # probability of crossing two selected inds
minw = 0
maxw = 1                # range of all parameters

ea = RealVectorEA(genomelen, False, maxGens, popSize, minw, maxw);
ea.mutate.setStdev(stDev);
ea.setProbabilities(pMut, pCross);

prevgen=0

filename = 'prosperities.txt'

# now run the EA, store the course of the prosperity (per time step) only for the first one (best one)
while(ea.wantsEval()):
    
    if(prevgen!=ea.generation()):
        prevgen=ea.generation()
        f=file(filename,'a+')
        f.write('%1.1f %1.6f %s\n'%((prevgen-1),ea.getBestInd().getFitness().getValue(),' '.join(map(str, ea.getBestInd().getGenome().getVector()))))
        f.close()
Example #4
0
# dt = 0.001

#runs = 5    # TODO
base = 'ea_params_'

###################################### set the EA parameters
genomelen = 3           # alpha, gamma, lambda
popSize = 3
maxGens = 1   
pMut = 0.05             # probability of mutating each gene
stDev = 1               # standard deviation of applied gaussian to a gene
pCross = 0.8            # probability of crossing two selected inds
minw = 0
maxw = 1                # range of all parameters

ea = RealVectorEA(genomelen, False, maxGens, popSize, minw, maxw);
ea.mutate.setStdev(stDev);
ea.setProbabilities(pMut, pCross);

prevgen=0

filename = 'prosperities.txt'
evaluated = 0
#TODO
name = 'x'
indNo=0

# build the model with default values
net = buildSimulation(QLambda.DEF_ALPHA,QLambda.DEF_GAMMA,QLambda.DEF_LAMBDA,QLambda.DEF_IMPORTANCE,name,indNo) 
rl = net.get("RL_QLambda")
importanceIn.setFunctions([ConstantFunction(1,0.5)]) # TODO find some optimal value
Example #5
0
t = 5000#50
dt = 0.1
#runs = 5    # TODO
base = 'ea_params_'

###################################### set the EA parameters
genomelen = 3           # alpha, gamma, lambda
popSize = 3
maxGens = 1   
pMut = 0.05             # probability of mutating each gene
stDev = 1               # standard deviation of applied gaussian to a gene
pCross = 0.8            # probability of crossing two selected inds
minw = 0
maxw = 1                # range of all parameters

ea = RealVectorEA(genomelen, False, maxGens, popSize, minw, maxw);
ea.mutate.setStdev(stDev);
ea.setProbabilities(pMut, pCross);

prevgen=0

filename = 'prosperities.txt'

# now run the EA, store the course of the prosperity (per time step) only for the first one (best one)
while(ea.wantsEval()):
    
    if(prevgen!=ea.generation()):
        prevgen=ea.generation()
        f=file(filename,'a+')
        f.write('%1.1f %1.6f %s\n'%((prevgen-1),ea.getBestInd().getFitness().getValue(),' '.join(map(str, ea.getBestInd().getGenome().getVector()))))
        f.close()