Algorithm-Evolutionary
view release on metacpan or search on metacpan
lib/Algorithm/Evolutionary/Op/Combined.pm view on Meta::CPAN
use strict;
use warnings;
=encoding utf8
=head1 NAME
Algorithm::Evolutionary::Op::Combined - Combinator of several operators of the same arity, unary or binary
=head1 SYNOPSIS
#Initialize using OO interface
my $op = new Algorithm::Evolutionary::Op::Mutation 0.1 3
my $another_op = new Algorithm::Evolutionary::Op::Permutation 2
# Single operator with rate of application = 3
my $combined_op = new Algorithm::Evolutionary::Op::Combined [ $op, $another_op ], 3;
=head1 Base Class
L<Algorithm::Evolutionary::Op::Base|Algorithm::Evolutionary::Op::Base>
=head1 DESCRIPTION
Some algorithms (such as
L<Algorithm::Evolutionary::Op::Canonical_GA_NN>) need a single
"mutation" and a single "crossover" operator. If you want to combine
several (like above, mutation and permutation), each one with its own
rate, you have to give them a façade like this one.
=head1 METHODS
=cut
package Algorithm::Evolutionary::Op::Combined;
use lib qw(../../..);
our $VERSION = '1.2';
use Algorithm::Evolutionary::Wheel;
use Carp;
use base 'Algorithm::Evolutionary::Op::Base';
#Class-wide constants
our $APPLIESTO = 'Algorithm::Evolutionary::Individual::String';
our $ARITY = 2;
our %parameters = ( numPoints => 2 );
=head2 new( $ref_to_operator_array [, $operation_priority] )
Priority defaults to one, operator array has no defaults.
=cut
sub new {
my $class = shift;
croak "Need operator array" if (!@_) ;
my $hash = { ops => shift };
my $rate = shift || 1;
my $self = Algorithm::Evolutionary::Op::Base::new( $class, $rate, $hash );
return $self;
}
( run in 1.343 second using v1.01-cache-2.11-cpan-5a3173703d6 )