Algorithm::Evolutionary::Individual::Base - Base class for chromosomes that knows how to build them, and has
               some helper methods.

  use  Algorithm::Evolutionary::Individual::Base;
  my $xmlStr="<indi type='BinaryIndi'><atom>1</atom><atom>0</atom><atom>1</atom><atom>0</atom></indi>";
  my $ref = XMLin($xmlStr);
  my $binIndi2 = Algorithm::Evolutionary::Individual::Base->fromXML( $ref ); #From XML fragment
  print $binIndi2->asXML();
  my $indi = Algorithm::Evolutionary::Individual::Base->fromParam( $ref->{initial}{section}{indi}{param} ); #From parametric description
  $binIndi2->Fitness( 3.5 ); #Sets or gets fitness
  print $binIndi2->Fitness();
  my $emptyIndi = new Algorithm::Evolutionary::Individual::Base;


Base class for individuals in evolutionary computation algorithms



Creates a new Base individual of the required class, with a fitness, and sets fitnes to undef. Takes as params a hash to the options of the individual, that will be passed on to the object of the class when it's initialized.


Creates a new random string, but uses a different interface: takes a ref-to-hash, with named parameters, which gives it a common interface to all the hierarchy. The main difference with respect to new is that after creation, it's initialized with random values.


Sets values of an individual; takes a hash as input. Keys are prepended an underscore and turn into instance variables


Takes a definition in the shape <indi><atom>....</indi><fitness></fitness></indi> and turns it into a bitstring, if it knows how to do it. The definition must have been processed using XML::Simple. It forwards stuff it does not know about to the corresponding subclass, which should implement the set method. The class it refers about is required in runtime.


Takes an array of params that describe the individual, and build it, with random initial values.

Params have this shape: <param name='type' value='Vector' /> <param name='length' value='2' /> <param name='range' start='0' end='1' />

The 'type' will show the class of the individuals that are going to be created, and the rest will be type-specific, and left to the particular object to interpret.


Prints it as XML. The caller must close the tags.


Sets or gets the value of an atom. Each individual is divided in atoms, which can be accessed sequentially. If that does not apply, Atom can simply return the whole individual


Sets or gets fitness


Sets or gets the chromosome itself, that is, the data structure evolved. Since each derived class has its own data structure, and its own name, it is left to them to return it

Known subclasses


  This file is released under the GPL. See the LICENSE file included in this distribution,
  or go to
  CVS Info: $Date: 2002/07/23 12:13:10 $ 
  $Header: /cvsroot/opeal/opeal/Algorithm/Evolutionary/Individual/,v 1.9 2002/07/23 12:13:10 jmerelo Exp $ 
  $Author: jmerelo $ 
  $Revision: 1.9 $
  $Name $