ec.cgp.representation
Class FloatVectorIndividual

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

public class FloatVectorIndividual
extends VectorIndividualCGP

Float-based genome representation of a Cartesian Genetic Program. Gene values are restricted to floats in the range [0,1]. During program evaluation, each float value is scaled to integers in the acceptable range that is imposed by the gene's position.

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

Field Summary
 float[] genome
          the genome
static java.lang.String P_FLOATVECTORINDIVIDUAL
           
 
Fields inherited from class ec.cgp.representation.VectorIndividualCGP
expression
 
Fields inherited from class ec.Individual
evaluated, EVALUATED_PREAMBLE, fitness, P_INDIVIDUAL, species
 
Constructor Summary
FloatVectorIndividual()
           
 
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 defaultCrossover(ec.EvolutionState state, int thread, ec.vector.VectorIndividual ind)
          Convex (or "arithmetic") crossover for real-valued genomes.
 void defaultCrossover2(ec.EvolutionState state, int thread, ec.vector.VectorIndividual ind)
          Any-point crossover.
 void defaultMutate(ec.EvolutionState state, int thread)
          Mutate the genome.
 boolean equals(java.lang.Object ind)
          Adapted from FloatVectorIndividual.
 long genomeLength()
          Return the length of the genome
 java.lang.String genotypeToString()
          Print to a string the genotype of the Individual in a fashion intended to be parsed in again via parseGenotype(...).
 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()
          Copied from FloatVectorIndividual
static void main(java.lang.String[] args)
           
static float randGaussian(ec.util.MersenneTwisterFast rand, float mean, float std)
          Generate a random value with a Gaussian distribution.
 void reset(ec.EvolutionState state, int thread)
          Initializes the individual by randomly choosing float values uniformly from mingene to maxgene.
 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.
static void testGaussian()
           
 
Methods inherited from class ec.vector.VectorIndividual
join, reset, setGenomeLength, size, split
 
Methods inherited from class ec.Individual
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_FLOATVECTORINDIVIDUAL

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

genome

public float[] genome
the genome

Constructor Detail

FloatVectorIndividual

public FloatVectorIndividual()
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 FloatVectorIndividual.

Overrides:
defaultMutate in class ec.vector.VectorIndividual

defaultCrossover2

public void defaultCrossover2(ec.EvolutionState state,
                              int thread,
                              ec.vector.VectorIndividual ind)
Any-point crossover.


defaultCrossover

public void defaultCrossover(ec.EvolutionState state,
                             int thread,
                             ec.vector.VectorIndividual ind)
Convex (or "arithmetic") crossover for real-valued genomes. It is shown to yield improved convergence for regression problems (see Clegg et. al., "A new crossover technique for Cartesian genetic programming"). But I have not yet seen convergence improvement for parity and classification problems.

Overrides:
defaultCrossover in class ec.vector.VectorIndividual

reset

public void reset(ec.EvolutionState state,
                  int thread)
Initializes the individual by randomly choosing float values uniformly from mingene to maxgene. Adapted from FloatVectorIndividual.

Specified by:
reset in class ec.vector.VectorIndividual

hashCode

public int hashCode()
Copied from FloatVectorIndividual

Specified by:
hashCode in class ec.Individual

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

genotypeToString

public java.lang.String genotypeToString()
Description copied from class: ec.Individual
Print to a string the genotype of the Individual in a fashion intended to be parsed in again via parseGenotype(...). The fitness and evaluated flag should not be included. The default form simply calls toString(), which is almost certainly wrong, and you'll probably want to override this to something else.

Overrides:
genotypeToString in class ec.Individual

equals

public boolean equals(java.lang.Object ind)
Adapted from FloatVectorIndividual.

Specified by:
equals in class ec.Individual

randGaussian

public static float randGaussian(ec.util.MersenneTwisterFast rand,
                                 float mean,
                                 float std)
Generate a random value with a Gaussian distribution. Currently unused but might be useful for some problems.

Parameters:
rand - The RNG to use.
mean - The mean we want for our random values.
std - The standard deviation we want for our random values.
Returns:
the random value

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 length of the genome

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

testGaussian

public static void testGaussian()

main

public static void main(java.lang.String[] args)