Basic usageΒΆ

Follow these steps to solve a basic regression problem:

  1. Define an objective function. The objective function takes an individual as an argument and updates the fitness of the individual.

    def objective(individual):
        individual.fitness = ...
        return individual
    
  2. Define a callback function to record information about the progress of the evolution:

    history = {}
    history["fitness_parents"] = []
    def recording_callback(pop):
        history["fitness_parents"].append(pop.fitness_parents())
    
  3. Use the evolve function that uses default hyperparameters and starts the evolution:

    cgp.evolve(obj, print_progress=True, callback=recording_callback)