Skip to content

Commit

Permalink
No need to update elites memory/fitness when the worker is done.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kilik Kuo committed May 31, 2017
1 parent 3869038 commit 2038b8a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions OpenCLGA/ocl_ga.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def next(self, action):
if self.openclga.action_callbacks and 'state' in self.openclga.action_callbacks:
self.openclga.action_callbacks['state'](next_state)

def is_running(self):
return self.__curr_state == 'running'

## A task to iterate GA generation in a separated thread.
class GARun(Task):
def __init__(self, ga, prob_mutation, prob_crossover, callback):
Expand Down Expand Up @@ -728,6 +731,8 @@ def get_the_best(self):
def update_elites(self, elites):
assert self.__is_elitism_mode, 'Elitism Mode is {}'.format(self.__is_elitism_mode)
assert len(elites) == self.__elitism_top
if not self.state_machine.is_running():
return
with self.__elite_lock:
elites_dna_data = []
elites_fitnesses = []
Expand Down

0 comments on commit 2038b8a

Please sign in to comment.