Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ahw627 committed Nov 23, 2018
1 parent 4663fdd commit 7a4c8d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions CMAES.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
pop_GA = 10 #population size in GA
pop_CMAES = 10 #population size in CMA-ES

ngen_GA = 2 #number of generations in GA
ngen_CMAES = 2 #number of generations in CMA-ES
ngen_GA = 3 #number of generations in GA
ngen_CMAES = 3 #number of generations in CMA-ES

reps_GA = 2 #repetitions of GA
reps_CMAES = 2 #repetitions of CMA-ES
reps_GA = 3 #repetitions of GA
reps_CMAES = 3 #repetitions of CMA-ES

sigma = 0.2 #sigma for CMA-ES

Expand Down
7 changes: 4 additions & 3 deletions GA.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def fitness_predictor(individual,arg,n):
for i in range(n,len(arg)):
if ((func(arg[i-n:i])>0)==(arg[i]>0)):
fit += -1
return fit/(len(arg)-n)*100,
# return fit/(len(arg)-n)*100,
return fit*fit/(len(arg)-n),

toolbox = base.Toolbox()

Expand Down Expand Up @@ -174,12 +175,12 @@ def run(cxpb,mutpb,n,tour,termpb,pop,ngen):
toolbox.register("map", futures.map) #PARALLELIZATION
elif parallel==2:
import multiprocessing
pool = multiprocessing.Pool()
pool = multiprocessing.Pool(6)
toolbox.register("map", pool.map) #PARALLELIZATION

pop = toolbox.population(n=pop)
hof = tools.HallOfFame(1)
pop, log = algorithms.eaSimple(pop, toolbox, cxpb, mutpb, ngen, stats=mstats, halloffame=hof, verbose=True)
pop, log = algorithms.eaSimple(pop, toolbox, cxpb, mutpb, ngen, stats=mstats, halloffame=hof, verbose=False)

return hof[0].fitness.values[0]

Expand Down

0 comments on commit 7a4c8d0

Please sign in to comment.