Algorithm-Evolutionary
view release on metacpan or search on metacpan
lib/Algorithm/Evolutionary/Op/ArithCrossover.pm view on Meta::CPAN
use strict;
use warnings;
use lib qw(../../..);
=head1 NAME
Algorithm::Evolutionary::Op::ArithCrossover - Arithmetic crossover operator; performs the average of the n parents crossed
=head1 SYNOPSIS
my $xmlStr6=<<EOC; #Create it from XML
<op name='ArithCrossover' type='binary' rate='1' />
EOC
my $ref6 = XMLin($xmlStr6);
my $op6 = Algorithm::Evolutionary::Op::Base->fromXML( $ref6 );
print $op6->asXML(), "\n";
$op6->apply( $indi4, $indi5 );
print $indi4->asString(), "\n"
my $op = new Algorithm::Evolutionary::Op::ArithCrossover; #Create from scratch
=head1 Base Class
L<Algorithm::Evolutionary::Op::Base|Algorithm::Evolutionary::Op::Base>
=head1 DESCRIPTION
Crossover operator for a vector-rep individual
=head1 METHODS
=cut
package Algorithm::Evolutionary::Op::ArithCrossover;
our $VERSION = sprintf "%d.%03d", q$Revision: 3.1 $ =~ /(\d+)\.(\d+)/g; # Hack for avoiding version mismatch
use Carp;
use Clone qw(clone);
use base 'Algorithm::Evolutionary::Op::Base';
#Class-wide constants
our $APPLIESTO = 'Algorithm::Evolutionary::Individual::Vector';
our $ARITY = 2;
=head2 create()
Creates the operator, but is more or less empty. Does not have instance variables
=cut
sub create {
my $class = shift;
my $self;
bless $self, $class;
return $self;
}
=head2 apply( $chromosome_1, $chromosome_2 )
Applies xover operator to a "Chromosome", a vector of stuff,
( run in 0.720 second using v1.01-cache-2.11-cpan-5a3173703d6 )