AI::Genetic::OpCrossover - A class that implements various crossover operators.
See AI::Genetic.
This package implements a few crossover mechanisms that can be used in user-defined strategies. The methods in this class are to be called as static class methods, rather than instance methods, which means you must call them as such:
AI::Genetic::OpCrossover::MethodName(arguments)
The following crossover operators are defined:
In single point crossover, a point is selected along the choromosomes of both parents. The chromosomes are then split at that point, and the head of one parent chromosome is joined with the tail of the other and vice versa, creating two child chromosomes. The following method is defined:
The first argument is the crossover rate. The second and third arguments are anonymous lists that define the genes of the parents (not AI::Genetic::Individual objects, but the return value of the genes() method in scalar context). If mating occurs, two anonymous lists of genes are returned corresponding to the two new children. If no mating occurs, 0 is returned.
In two point crossover, two points are selected along the choromosomes of both parents. The chromosomes are then cut at those points, and the middle parts are swapped, creating two child chromosomes. The following method is defined:
In uniform crossover, two child chromosomes are created by looking at each gene in both parents, and randomly selecting which one to go with each child. The following method is defined:
Written by Ala Qumsieh aqumsieh@cpan.org.
(c) 2003,2004 Ala Qumsieh. All rights reserved. This module is distributed under the same terms as Perl itself.
To install AI::Genetic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AI::Genetic
CPAN shell
perl -MCPAN -e shell install AI::Genetic
For more information on module installation, please visit the detailed CPAN module installation guide.