Help language development. Donate to The Perl Foundation
Algorithm::Evolutionary::Simple - A simple evolutionary algorithm
Algorithm::Evolutionary::Simple is a module for writing simple and quasi-canonical evolutionary algorithms in Perl 6. It uses binary representation, integer fitness (which is needed for the kind of data structure we are using) and a single fitness function.
It is intended mainly for demo purposes. In the future, more versions will be available.
It uses a fitness cache for storing and not reevaluating, so take care of memory bloat.
Creates the initial population
Generates a random chromosome
Returns the number of trues or ones in the chromosome
That's a bumpy road, returns 1 for each block of 4 which has the same true or false value.
Evaluates the chromosomes, storing values in the fitness cache.
Roulette wheel selection.
Returns the chromosome with a random bit flipped
Returns two cromosomes, with parts of it crossed over
Produces offspring from a pool array
Returns the fitness of the first element.
Single generation of an evolutionary algorithm. The initial Bag has to be evaluated before entering here using the
Mixes the two populations, returning a single one of the indicated size
There is a very interesting implementation of an evolutionary algorithm in Algorithm::Genetic. Check it out. This is also a port of Algorithm::Evolutionary::Simple in Perl6, which has a few more goodies.
JJ Merelo email@example.com
Copyright 2018 JJ Merelo
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.