High-level API

cgp.evolve(pop: cgp.population.Population, objective: Callable[[cgp.individual.IndividualBase], cgp.individual.IndividualBase], ea: cgp.ea.mu_plus_lambda.MuPlusLambda, min_fitness: float = inf, termination_fitness: float = inf, max_generations: int = inf, max_objective_calls: int = inf, print_progress: Optional[bool] = False, callback: Optional[Callable[[cgp.population.Population], None]] = None) → None[source]

Evolves a population and returns the history of fitness of parents.

popPopulation

A population class that will be evolved.

objectiveCallable

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

eaEA algorithm instance

The evolution algorithm. Needs to be a class instance with an initialize_fitness_parents and step method.

min_fitnessfloat

Minimum fitness at which the evolution is stopped. Warning: This argument is deprecated and will be removed in the 0.4 release. Please use termination_fitness instead.

termination_fitnessfloat

Minimum fitness at which the evolution is terminated

max_generationsint

Maximum number of generations. Defaults to positive infinity. Either this or max_objective_calls needs to be set to a finite value.

max_objective_calls: int

Maximum number of function evaluations. Defaults to positive infinity.

print_progressboolean, optional

Switch to print out the progress of the algorithm. Defaults to False.

callbackcallable, optional

Called after each iteration with the population instance. Defaults to None.

None