Skip to content

Commit

Permalink
Refactor adaptive pop size
Browse files Browse the repository at this point in the history
  • Loading branch information
YamLyubov committed Jul 31, 2023
1 parent 525bb7b commit e643517
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions golem/core/optimisers/genetic/parameters/population_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,13 @@ def initial(self) -> int:
return self._initial

def next(self, population: PopulationT) -> int:
fitness_improved = self._improvements.is_quality_improved
complexity_decreased = self._improvements.is_complexity_improved
progress_in_both_goals = fitness_improved and complexity_decreased
no_progress = not fitness_improved and not complexity_decreased
pop_size = len(population)
too_many_fitness_eval_errors = \
pop_size / self._iterator.current() < 0.5
too_many_fitness_eval_errors = pop_size / self._iterator.current() < 0.5

if too_many_fitness_eval_errors or no_progress:
if too_many_fitness_eval_errors or not self._improvements.is_any_improved:
if self._iterator.has_next():
pop_size = self._iterator.next()
elif progress_in_both_goals and pop_size > 0:
elif self._improvements.is_quality_improved and self._improvements.is_complexity_improved and pop_size > 0:
if self._iterator.has_prev():
pop_size = self._iterator.prev()

Expand Down

0 comments on commit e643517

Please sign in to comment.