Evolutionary Algorithms

class cgp.ea.MuPlusLambda(n_offsprings: int, mutation_rate: float, *, tournament_size: Optional[int] = None, n_processes: int = 1, local_search: Optional[Callable[[cgp.individual.IndividualBase], None]] = None, k_local_search: Optional[int] = None, reorder_genome: bool = False, hurdle_percentile: List = [0.0])[source]

Generic (mu + lambda) evolution strategy based on Deb et al. (2002).

Currently only uses a single objective.

Deb, K., Pratap, A., Agarwal, S., & Meyarivan, T. A. M. T. (2002). A fast and elitist multiobjective genetic algorithm: NSGA-II. IEEE transactions on evolutionary computation, 6(2), 182-197.

initialize_fitness_parents(pop: cgp.population.Population, objective: Callable[[cgp.individual.IndividualBase], cgp.individual.IndividualBase]) → None[source]

Initialize the fitness of all parents in the given population.

popPopulation

Population instance.

objectiveCallable[[gp.IndividualBase], gp.IndividualBase]

An objective function used for the evolution. Needs to take an individual (IndividualBase) as input parameter and return a modified individual (with updated fitness).

mutate(offsprings: List[cgp.individual.IndividualBase], rng: numpy.random.mtrand.RandomState) → List[cgp.individual.IndividualBase][source]

Mutate a list of offspring individuals.

offspringsList[IndividualBase]

List of offspring individuals to be mutated.

rng: np.random.RandomState

List[IndividualBase]

List of mutated offspring individuals.

step(pop: cgp.population.Population, objective: Callable[[cgp.individual.IndividualBase], cgp.individual.IndividualBase]) → cgp.population.Population[source]

Perform one step in the evolution.

popPopulation

Population instance.

objectiveCallable[[gp.IndividualBase], gp.IndividualBase]

An objective function used for the evolution. Needs to take an individual (IndividualBase) as input parameter and return a modified individual (with updated fitness).

Population

Modified population with new parents.

update_n_objective_calls(combined: List[cgp.individual.IndividualBase]) → None[source]

Increase n_objective_calls by the number of individuals with fitness=None, i.e., for which the objective function will be evaluated.