Skip to content

Commit

Permalink
Add minimal mutation probability
Browse files Browse the repository at this point in the history
  • Loading branch information
YamLyubov committed Jul 31, 2023
1 parent 5627573 commit 525bb7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions golem/core/optimisers/genetic/gp_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def _update_requirements(self):
if not self.generations.is_any_improved:
self.graph_optimizer_params.mutation_prob, self.graph_optimizer_params.crossover_prob = \
self._operators_prob.next(self.population)
self.log.info(
f'Next mutation proba: {self.graph_optimizer_params.mutation_prob}; '
f'Next crossover proba: {self.graph_optimizer_params.crossover_prob}')
self.graph_optimizer_params.pop_size = self._pop_size.next(self.population)
self.requirements.max_depth = self._graph_depth.next()
self.log.info(
Expand Down
3 changes: 2 additions & 1 deletion golem/core/optimisers/genetic/parameters/mutation_prob.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class AdaptiveMutationProb(AdaptiveParameter[float]):
def __init__(self, default_prob: float = 0.5):
self._current_std = 0.
self._max_std = 0.
self._min_proba = 0.05
self._default_prob = default_prob

@property
Expand All @@ -23,7 +24,7 @@ def next(self, population: PopulationT) -> float:
elif self._max_std == 0:
mutation_prob = self._default_prob
else:
mutation_prob = 1. - (self._current_std / self._max_std)
mutation_prob = max(1. - (self._current_std / self._max_std), self._min_proba)
return mutation_prob

def _update_std(self, population: PopulationT):
Expand Down

0 comments on commit 525bb7b

Please sign in to comment.