Skip to content

Commit

Permalink
added termination if long time since last peak
Browse files Browse the repository at this point in the history
  • Loading branch information
sverrejb committed Mar 23, 2017
1 parent e5ab116 commit 255d5aa
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions EA/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def main():
worst_list = []
os.makedirs(ct.EXPERIMENT_FOLDER)
global_maximum = 0
best_median = 0
last_improvement = 0
alpha_deck = []

for gen in range(ct.NUMBER_OF_GENERATIONS):
Expand All @@ -111,6 +113,9 @@ def main():
strongest_individual = tools.selBest(population, k=1)

median_score = median(fitness_list)
if median_score > best_median:
best_median = median_score
last_improvement = gen

if maximum >= global_maximum:
global_maximum = maximum
Expand All @@ -119,6 +124,9 @@ def main():
if median_score >= 65:
break

if gen - last_improvement > 60:
break

top_list.append(maximum)
median_list.append(median_score)
worst_list.append(min(fitness_list))
Expand Down

0 comments on commit 255d5aa

Please sign in to comment.