Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ahw627 committed Nov 21, 2018
1 parent 5a3bb4f commit 955181e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions GA.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def __getitem__(self, key):
n=10
vec=[0]*N
for i in range(1,N):
# vec[i]=math.sin(i/5.)
vec[i]=math.sin(i/5.)
# vec[i]=random.uniform(-1,1)
vec[i]=-i
# vec[i]=-i
arr=array(vec)

pset = gp.PrimitiveSetTyped("main", [array], float)
Expand Down Expand Up @@ -167,7 +167,7 @@ def fitness_predictor(individual,arg):

toolbox.register("evaluate", fitness_predictor, arg=arr)

toolbox.register("select", tools.selBest)
toolbox.register("select", tools.selTournament, tournsize=3)
toolbox.register("mate", gp.cxOnePointLeafBiased,termpb=0.2)
toolbox.register("expr_mut", genGrow_edit, min_=0, max_=5)
toolbox.register("mutate", gp.mutUniform, expr=toolbox.expr_mut, pset=pset)
Expand All @@ -193,7 +193,7 @@ def fitness_predictor(individual,arg):
def main():
pop = toolbox.population(n=100)
hof = tools.HallOfFame(1)
pop, log = algorithms.eaSimple(pop, toolbox, 0.5, 0.3, 50, stats=mstats,
pop, log = algorithms.eaSimple(pop, toolbox, 0.5, 0.1, 100, stats=mstats,
halloffame=hof, verbose=True)
#print(arr,SMA(arr,4,2))
print(hof[0])
Expand Down

0 comments on commit 955181e

Please sign in to comment.