1.6. Operation probability functions

Simple functions for performing operator probability checks.

1.6.1. Crossover probability

natural_selection.genetic_algorithms.utils.probability_functions.crossover_prob_function_classic(crossover_probability: float = 0.5, island=None)

Classic crossover probability function that evaluates whether a random float is less than the crossover probability.

Parameters
  • crossover_probability (float) – Probability of crossover (default = 0.5).

  • island (Island) – The Island calling the method (default = None).

Returns

Returns whether to perform crossover.

Return type

bool

1.6.2. Mutation probability

natural_selection.genetic_algorithms.utils.probability_functions.mutation_prob_function_classic(mutation_probability: float = 0.2, island=None)float

Classic mutation probability function that evaluates whether a random float is less than the mutation probability.

Parameters
  • mutation_probability (float) – Probability of mutation (default = 0.2).

  • island (Island) – The Island calling the method (default = None).

Returns

Returns whether to perform mutation.

Return type

bool