ec.cgp.representation
Class IntegerVectorIndividual

java.lang.Object
  extended by ec.Individual
      extended by ec.vector.VectorIndividual
          extended by ec.cgp.representation.VectorIndividualCGP
              extended by ec.cgp.representation.IntegerVectorIndividual
All Implemented Interfaces:
ec.Prototype, ec.Setup, java.io.Serializable, java.lang.Cloneable

public class IntegerVectorIndividual
extends VectorIndividualCGP

Integer-based genome representation of a Cartesian Genetic Program. Each integer value is restricted to a range that is a function of its position in the genome.

Author:
David Oranchak, doranchak@gmail.com, http://oranchak.com
See Also:
Serialized Form

Field Summary
 int[] genome
          the genome
static java.lang.String P_INTEGERVECTORINDIVIDUAL
           
 
Fields inherited from class ec.cgp.representation.VectorIndividualCGP
expression
 
Fields inherited from class ec.Individual
evaluated, EVALUATED_PREAMBLE, fitness, P_INDIVIDUAL, species
 
Constructor Summary
IntegerVectorIndividual()
           
 
Method Summary
 java.lang.Object clone()
          Make a full copy of this individual.
 ec.util.Parameter defaultBase()
          Returns the default base for this prototype.
 void defaultMutate(ec.EvolutionState state, int thread)
          Mutate the genome.
 boolean equals(java.lang.Object ind)
          Returns true if I am genetically "equal" to ind.
 long genomeLength()
          Return the genome length
 java.lang.String genotypeToStringForHumans()
          Generate the human-readable text of the genotype, including the program's expression.
 java.lang.Object getGenome()
          Get the genome.
 int hashCode()
          Returns a hashcode for the individual, such that individuals which are equals(...) each other always return the same hash code.
 int randomValueFromClosedInterval(int min, int max, ec.util.MersenneTwisterFast random)
          Taken from IntegerVectorIndividual: Returns a random value from between min and max inclusive.
 void reset(ec.EvolutionState state, int thread)
          Initialize individual.
 void setGenome(java.lang.Object gen)
          Set the genome.
 void setup(ec.EvolutionState state, ec.util.Parameter base)
          Sets up the object by reading it from the parameters stored in state, built off of the parameter base base.
 
Methods inherited from class ec.vector.VectorIndividual
defaultCrossover, join, reset, setGenomeLength, size, split
 
Methods inherited from class ec.Individual
genotypeToString, parseGenotype, printIndividual, printIndividual, printIndividualForHumans, readGenotype, readIndividual, readIndividual, toString, writeGenotype, writeIndividual
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

P_INTEGERVECTORINDIVIDUAL

public static final java.lang.String P_INTEGERVECTORINDIVIDUAL
See Also:
Constant Field Values

genome

public int[] genome
the genome

Constructor Detail

IntegerVectorIndividual

public IntegerVectorIndividual()
Method Detail

defaultBase

public ec.util.Parameter defaultBase()
Description copied from interface: ec.Prototype
Returns the default base for this prototype. This should generally be implemented by building off of the static base() method on the DefaultsForm object for the prototype's package. This should be callable during setup(...).


clone

public java.lang.Object clone()
Make a full copy of this individual.

Specified by:
clone in interface ec.Prototype
Overrides:
clone in class ec.Individual

defaultMutate

public void defaultMutate(ec.EvolutionState state,
                          int thread)
Mutate the genome. Adapted from IntegerVectorIndividual. The acceptable value range for each position is determined by CGPVectorSpecies.computeMaxGene.

Overrides:
defaultMutate in class ec.vector.VectorIndividual

reset

public void reset(ec.EvolutionState state,
                  int thread)
Initialize individual.

Specified by:
reset in class ec.vector.VectorIndividual

genotypeToStringForHumans

public java.lang.String genotypeToStringForHumans()
Generate the human-readable text of the genotype, including the program's expression.

Overrides:
genotypeToStringForHumans in class ec.Individual

hashCode

public int hashCode()
Description copied from class: ec.Individual
Returns a hashcode for the individual, such that individuals which are equals(...) each other always return the same hash code.

Specified by:
hashCode in class ec.Individual

equals

public boolean equals(java.lang.Object ind)
Description copied from class: ec.Individual
Returns true if I am genetically "equal" to ind. This should mostly be interpreted as saying that we are of the same class and that we hold the same data. It should NOT be a pointer comparison.

Specified by:
equals in class ec.Individual

randomValueFromClosedInterval

public int randomValueFromClosedInterval(int min,
                                         int max,
                                         ec.util.MersenneTwisterFast random)
Taken from IntegerVectorIndividual: Returns a random value from between min and max inclusive. This method handles overflows that complicate this computation. Does NOT check that min is less than or equal to max. You must check this yourself.


getGenome

public java.lang.Object getGenome()
Get the genome.

Specified by:
getGenome in class VectorIndividualCGP

setGenome

public void setGenome(java.lang.Object gen)
Set the genome.

Overrides:
setGenome in class ec.vector.VectorIndividual

genomeLength

public long genomeLength()
Return the genome length

Overrides:
genomeLength in class ec.vector.VectorIndividual

setup

public void setup(ec.EvolutionState state,
                  ec.util.Parameter base)
Description copied from interface: ec.Prototype
Sets up the object by reading it from the parameters stored in state, built off of the parameter base base. If an ancestor implements this method, be sure to call super.setup(state,base); before you do anything else.

For prototypes, setup(...) is typically called once for the prototype instance; cloned instances do not receive the setup(...) call. setup(...) may be called more than once; the only guarantee is that it will get called at least once on an instance or some "parent" object from which it was ultimately cloned.

Specified by:
setup in interface ec.Prototype
Specified by:
setup in interface ec.Setup
Overrides:
setup in class ec.Individual