StringIndi - A character string to be evolved. Useful mainly in word games
my $indi = new StringIndi 10 [a..z]; # Build random bitstring with length 10 # Each element in the range 0 .. 1
my $indi3 = new StringIndi; $indi3->set( _length => 20, _chars => [A..Z] ); #Sets values, but does not build the string $indi3->randomize(); #Creates a random bitstring with length as above print $indi3->Atom( 7 ); #Returns the value of the 7th character $indi3->Atom( 3 ) = 'q'; #Sets the value
$indi3->addAtom( 'k' ); #Adds a new character to the bitstring at the end
my $indi4 = StringIndi->fromString( 'esto es un string'); #Creates an individual from that string
my $indi5 = $indi4->clone(); #Creates a copy of the individual
print $indi3->asString(); #Prints the individual print $indi3->asXML() #Prints it as XML. See
String Individual for ao GA
Creates a new random string, with fixed initial length, and uniform distribution of characters along the character class that is defined.
Sets values of an individual; takes a hash as input
Assigns random values to the elements
Adds an atom at the end
Similar to a copy ctor; creates a bitstring individual from a string
Similar to a copy ctor: creates a new individual from another one
Prints it
Sets or gets the value of the n-th character in the string
Prints it as XML. See the XML manpage for more info on this
Sets or gets the array that holds the chromosome. Not very nice, and I would never ever do this in C++
This file is released under the GPL. See the LICENSE file included in this distribution, or go to http://www.fsf.org/licenses/gpl.txt
CVS Info: $Date: 2001/11/29 18:44:27 $ $Header: /cvsroot/opeal/opeal/StringIndi.pm,v 1.7 2001/11/29 18:44:27 jmerelo Exp $ $Author: jmerelo $ $Revision: 1.7 $