This is a simple Genetic Programming library for Java. It is easy to follow and has no external dependencies.
The best way to learn it at the moment is to browse through its unit tests.
EvolutionEngineTest.testEvolution()
- Initialises and runs the Evolution Engine.
In this simple example, the fitness function promotes the "dominant" genes 0
and 1
and ingnores the "useless" .
gene.
The initial generation
Chromosome Fitness Score
========== =============
010101010101010101010101010101010101010101010101 0.5
10101010101010101010101.....01010101010101010101 0.4583333333333333
01010101010110101.....................0101010101 0.2916666666666667
10101010101010101010..........101010101010101010 0.3958333333333333
01010010...010101010101....011010101101010101010 0.4375
101010010101010101010101010101101010101010101010 0.5
0101010101010101...10101010101010101101010101010 0.4791666666666667
1010101010101.........01010101010101010101101010 0.4166666666666667
01010101.................0101010..........101010 0.22916666666666666
10101010101............010101010..........101010 0.2708333333333333
01010101010101010101010101010101...........01010 0.3958333333333333
101010101010101010010101010101010101010101101010 0.5
010101010101101....01010101010101010101010101010 0.4583333333333333
101010101010101010101010101010101010101010101010 0.5
evolves into this (0
has won)
Chromosome Fitness Score
========== =============
000000000000000000000000000000010000000000000000 0.9791666666666666
000000000000000000000000000000010000000000000000 0.9791666666666666
000000000000000000000000000000010000000000000000 0.9791666666666666
000000000000000000000000000000001000000000000000 0.9791666666666666
000000000000000000000000000000010000000000000000 0.9791666666666666
000000000000000000000000000000010000000000000000 0.9791666666666666
001000000000000000000000000000010000000000000000 0.9583333333333334
000000000000000000000000000000000000000000000000 1.0 <- Winner!
000000000000000000000000000000010000000000000000 0.9791666666666666
000000000000000000000000000000010000000000000000 0.9791666666666666
000000000000000100000000000000000000000000000000 0.9791666666666666
000000000000000000000000000000010000000000000000 0.9791666666666666
000000000000000000000000000000010000000000000000 0.9791666666666666
000000000000000000000000000000010000000000000000 0.9791666666666666
Here is the alterntive outcome (1
has won):
Chromosome Fitness Score
========== =============
111111111111101111111111111111011111111111111111 0.9583333333333334
111111101111111111111111111111011111110111111111 0.9375
111111111110111111111111011111111111111111111111 0.9583333333333334
111111101111111111111111111111011111111111111101 0.9375
111111111110111111111111111111011111110111111111 0.9375
111111101111111111111111111111011111111111111101 0.9375
111111111111101111111111111111011111111111111111 0.9583333333333334
111111101111111111111111111111011111110111111111 0.9375
111111111110111111111111111111111111111111111111 0.9791666666666666
111111101111111111111111011111011111110111111101 0.8958333333333334
111111111111111111111111111111111111111111111111 1.0 <- Winner!
111111101111111111111111011111111111111111111101 0.9375
111111111110111111111111111111011111110111111101 0.9166666666666666
111110111110111111111111111111011111110111111111 0.9166666666666666
Enjoy! โ