Algorithm::Evolutionary::Op::Uniform_Crossover - interchanges a set of atoms from one parent to the other.
#Create from XML description using EvoSpec my $xmlStr3=<<EOC; <op name='Uniform_Crossover' type='binary' rate='1'> <param name='numPoints' value='3' /> #Max is 2, anyways </op> EOC my $op3 = Algorithm::Evolutionary::Op::Base->fromXML( $xmlStr3 ); print $op3->asXML(), "\n"; #Apply to 2 Individuals of the String class my $indi = new Algorithm::Evolutionary::Individual::BitString 10; my $indi2 = $indi->clone(); my $indi3 = $indi->clone(); my $offspring = $op3->apply( $indi2, $indi3 ); #$indi2 == $offspring #Initialize using OO interface my $op4 = new Algorithm::Evolutionary::Op::Uniform_Crossover 0.5;# Crossover rate
Algorithm::Evolutionary::Op::Base
General purpose uniform crossover operator
Creates a new n-point crossover operator, with 2 as the default number of points, that is, the default would be my $options_hash = { crossover_rate => 0.5 }; my $priority = 1;
Applies xover operator to a "Chromosome", a string, really. Can be applied only to victims with the _str instance variable; but it checks before application that both operands are of type String.
_str
Changes the first parent, and returns it. If you want to change both parents at the same time, check QuadXOver
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: 2011/02/14 06:55:36 $ $Header: /media/Backup/Repos/opeal/opeal/Algorithm-Evolutionary/lib/Algorithm/Evolutionary/Op/Uniform_Crossover.pm,v 3.2 2011/02/14 06:55:36 jmerelo Exp $ $Author: jmerelo $ $Revision: 3.2 $ $Name $
To install Algorithm::Evolutionary, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Algorithm::Evolutionary
CPAN shell
perl -MCPAN -e shell install Algorithm::Evolutionary
For more information on module installation, please visit the detailed CPAN module installation guide.