示例#1
0
soup = CoreSoup().register_input("lst", List[int])

# The spawner which will generate random genes and genomes.
spawner = Spawner(soup)

# The parent selector.
selector = Lexicase(epsilon=False)

# The evolver
evo = GeneticAlgorithm(
    error_function=error,
    spawner=spawner,
    selector=selector,
    variation=VariationSet([
        (size_neutral_umad, 1.0),
        # (Alternation(), 0.2),
        # (Genesis(size=(50, 50)), 1.0),
    ]),
    population_size=1000,
    max_generations=300,
    initial_genome_size=(5, 30)
)

simplifier = GenomeSimplifier(error, int)

if __name__ == "__main__":
    best = evo.run(int)
    print(best.program.to_def("sum_increments", ["lst"]))
    simp_best = simplifier.simplify(best)
    print(simp_best.program.to_def("sum_increments", ["lst"]))