NAME
Algorithm::Evolutionary::Op::FullAlgorithm - Skeleton class for a fully-featured evolutionary algorithm
SYNOPSIS
my $easyEA = Algorithm::Evolutionary::Op::Base->fromXML( $ref->{$xml} );
$easyEA->apply(\@pop );
#Or using the constructor
use Algorithm::Evolutionary::Op::Bitflip;
my $m = new Algorithm::Evolutionary::Op::Bitflip; #Changes a single bit
my $c = new Algorithm::Evolutionary::Op::Crossover; #Classical 2-point crossover
my $replacementRate = 0.3; #Replacement rate
use Algorithm::Evolutionary::Op::RouletteWheel;
my $popSize = 20;
my $selector = new Algorithm::Evolutionary::Op::RouletteWheel $popSize; #One of the possible selectors
use Algorithm::Evolutionary::Op::GeneralGeneration;
my $onemax = sub {
my $indi = shift;
my $total = 0;
my $len = $indi->length();
my $i = 0;
while ($i < $len ) {
$total += substr($indi->{'_str'}, $i, 1);
$i++;
}
return $total;
};
my $generation =
new Algorithm::Evolutionary::Op::GeneralGeneration( $onemax, $selector, [$m, $c], $replacementRate );
use Algorithm::Evolutionary::Op::GenerationalTerm;
my $g100 = new Algorithm::Evolutionary::Op::GenerationalTerm 10;
use Algorithm::Evolutionary::Op::FullAlgorithm;
my $f = new Algorithm::Evolutionary::Op::FullAlgorithm $generation, $g100;
print $f->asXML();
Base Class
Algorithm::Evolutionary::Op::Base
DESCRIPTION
Class Easy-to-use full evolutionary algoritm.It takes a single-generarion algorithm, and mixes it with a termination condition to create a full algorithm. Includes a sensible default (100-generation generational algorithm) if it is issued only an object of class Algorithm::Evolutionary::Op::GeneralGeneration.
new( $single_generation[, $termination_test] [, $verboseness] )
Takes an already created algorithm and a terminator, and creates an object
set( $hashref, $codehash, $opshash )
Sets the instance variables. Takes hashes to the different options of the algorithm: parameters, fitness functions and operators
apply( $reference_to_population_array )
Applies the algorithm to the population; checks that it receives a ref-to-array as input, croaks if it does not. Returns a sorted, culled, evaluated population for next generation.
Copyright
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/02/06 16:03:04 $
$Header: /cvsroot/opeal/Algorithm-Evolutionary/lib/Algorithm/Evolutionary/Op/FullAlgorithm.pm,v 2.2 2009/02/06 16:03:04 jmerelo Exp $
$Author: jmerelo $