|
AI::Genetic::Individual - Base class for AI::Genetic Individuals. |
AI::Genetic::Individual - Base class for AI::Genetic Individuals.
This package implements the base class for all AI::Genetic individuals. It provides basic methods required by AI::Genetic for correct evolution. Furthermore, it can be very easily used as a base class for additional types of individuals. AI::Genetic comes with three individual types that inherit from this class. These are IndBitVector, IndListVector, and IndRangeVector.
See CREATING YOUR OWN INDIVIDUAL CLASS for more details.
The following methods are accessible publicly. They are not meant to be over-ridden:
If called as an instance method, it expects one argument which defines the genes of the individual. All other attributes, like fitness function, class, etc, will be copied from the calling instance.
If called as a class method, then it calls newSpecific(). See below for details.
score() will return the cached value.
The following methods are meant to be over-ridden by any class that inherits from AI::Genetic::Individual:
AI::Genetic::IndBitVector->new([0, 1, 1, 0, 1, 0]);
AI::Genetic::IndListVector->new(
[qw/red medium fat/], # genes
[ # possible values
[qw/red blue green/],
[qw/big medium small/],
[qw/very_fat fat fit thin very_thin/],
]);
AI::Genetic::IndListVector->new(
[3, 14, 4], # genes
[ # possible values
[1, 5],
[0, 20],
[4, 9],
]);
Other useful non-generic methods:
Creating your own individual class is easy. All you have to do is inherit from AI::Genetic::Individual and override the newRandom(), newSpecific, and genes() methods to conform with the documentation above. Specifically, the arguments to i<newRandom> and newSpecific have to match what AI::Genetic::init() expects as arguments. You can also define any additional methods that you might require in your own custom-made strategies.
Note that in order for your own individual class to be useful, you have to define your own custom strategy that knows how to evolve such individuals. Conceptually, this should be very simple.
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.
|
AI::Genetic::Individual - Base class for AI::Genetic Individuals. |