High-level API

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

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

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).

popPopulation, optional

A population class that will be evolved. Defaults to population with default parameters.

eaEA algorithm instance, optional

The evolutionary algorithm. Defaults to MuPlusLambda.

termination_fitnessfloat, optional

Minimum fitness at which the evolution is terminated. Defaults to positive infinity.

max_generationsint, optional

Maximum number of generations. If neither this nor max_objective_calls are set, max_generations defaults to 1000.

max_objective_calls: int, optional

Maximum number of function evaluations. Defaults to largest representable integer. If neither this nor max_generations are set, max_generations defaults to 1000.

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.

Population

The evolved population.