29 Mar 2021 11:30:17 UTC
- Distribution: Algorithm-Evolutionary
- Source (raw)
- Browse (raw)
- How to Contribute
- Repository (git clone)
- Issues (0)
- Testers (64 / 0 / 0)
- KwaliteeBus factor: 1
- License: open_source
- Activity24 month
- Download (97.19KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:1 non-PAUSE userJMERELO J. J. Merelo-Guervósand 1 contributors
- JJ Merelo <jj /at/ merelo.net>
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
canonical-genetic-algorithm.pl - Canonical Genetic Algorithm on a simple fitness function
prompt% ./canonical-genetic-algorithm.pl <bits> <block size> <population> <number of generations> <selection rate>
A canonical GA uses mutation, crossover, binary representation, and roulette wheel selection. Here mainly for reference, and so that you can peruse to start your own programs.
In this case, we are optimizing the Royal Road function, http://web.cecs.pdx.edu/~mm/handbook-of-ec-rr.pdf. By default, these values are used:
number of bits: 64 (this is the chromosome length)
size of block: 4 (RR goes by blocks)
population size: 256
number of generations: 200 (could end before, if solution is found)
selection rate: 20% (will be replaced each generation); this means it's a steady state algorithm, which only changes a part of the population each generation.
This program also demonstrates the use of caches in the fitness evaluation, so be careful if you use too many bits or too many generations, check the memory.
Output shows the number of generations, the winning chromosome, and fitness. After finishing, it outputs time, cache ratio and some other things.
First, you should obviously check Algorithm::Evolutionary::Op::CanonicalGA, and then these other classes.
J. J. Merelo,
jj (at) merelo.net
This file is released under the GPL. See the LICENSE file included in this distribution, or go to http://www.fsf.org/licenses/gpl.txt CVS Info: $Date: 2009/07/30 07:48:48 $ $Header: /media/Backup/Repos/opeal/opeal/Algorithm-Evolutionary/scripts/canonical-genetic-algorithm.pl,v 3.1 2009/07/30 07:48:48 jmerelo Exp $ $Author: jmerelo $ $Revision: 3.1 $
Module Install Instructions
To install Algorithm::Evolutionary, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Algorithm::Evolutionary
For more information on module installation, please visit the detailed CPAN module installation guide.