Algorithm-Evolutionary
view release on metacpan or search on metacpan
lib/Algorithm/Evolutionary/Op/GaussianMutation.pm view on Meta::CPAN
use strict;
use warnings;
use lib qw(../../..);
=encoding utf8
=head1 NAME
Algorithm::Evolutionary::Op::GaussianMutation - Changes numeric chromosome components following the gaussian distribution.
=cut
=head1 SYNOPSIS
my $op = new Algorithm::Evolutionary::Op::GaussianMutation( 0, 0.05) # With average 0, and 0.05 standard deviation
=cut
=head1 Base Class
L<Algorithm::Evolutionary::Op::Base|Algorithm::Evolutionary::Op::Base>
=cut
=head1 DESCRIPTION
Mutation operator for a GA: applies gaussian mutation to a number
=cut
package Algorithm::Evolutionary::Op::GaussianMutation;
our $VERSION = '3.4';
use Carp;
use Math::Random;
use Clone qw(clone);
use base 'Algorithm::Evolutionary::Op::Base';
#Class-wide constants
our $APPLIESTO = 'Algorithm::Evolutionary::Individual::Vector';
our $ARITY = 1;
=head2 new( [$average = 0] [, $standard deviation = 1] [, $rate = 1 ]
Creates a new mutation operator with an application rate. Rate defaults to 1.
=cut
sub new {
my $class = shift;
my $avg = shift || 0;
my $stddev = shift || 1;
my $rate = shift || 1;
my $hash = {avg => $avg,
stddev => $stddev };
my $self = Algorithm::Evolutionary::Op::Base::new( 'Algorithm::Evolutionary::Op::GaussianMutation', $rate, $hash );
return $self;
}
=head2 create
Creates a new mutation operator with an application rate. Rate defaults to 0.1.
( run in 0.335 second using v1.01-cache-2.11-cpan-99c4e6809bf )