org.vizzini.ai.geneticprogramming
Class AbstractChromosomeGP

java.lang.Object
  extended by org.vizzini.ai.geneticalgorithm.AbstractChromosome
      extended by org.vizzini.ai.geneticprogramming.AbstractChromosomeGP
All Implemented Interfaces:
Cloneable, Comparable, IChromosome, IChromosomeGP
Direct Known Subclasses:
DefaultChromosomeGP

public abstract class AbstractChromosomeGP
extends AbstractChromosome
implements IChromosomeGP

Provides base functionality for a chromosome in genetic programming.

Since:
v0.3
Version:
v0.3
Author:
Jeffrey M. Thompson

Field Summary
 
Fields inherited from interface org.vizzini.ai.geneticalgorithm.IChromosome
UNKNOWN_FITNESS
 
Constructor Summary
AbstractChromosomeGP()
          Construct this object.
AbstractChromosomeGP(IFunction function)
          Construct this object with the given parameter.
 
Method Summary
 Object clone()
          Return a clone of this instance.
 Object evaluate(IContext context)
          Evaluate this function.
 IFunction getFunction()
           
 void mix(IChromosome c1, IChromosome c2, boolean[] mask)
          Mix the genes of the given chromosomes into this using the given mask.
 void mutate(double mutationRate, double mutationMagnitude)
          Mutate this chromosome's genes using the given parameters.
 void randomlyInitialize()
          Initialize the genes with random values.
 void setFunction(IFunction function)
           
 int size()
          Return the number of genes.
 void splice(IChromosomeGP chromosome0, IChromosomeGP chromosome1, int cut0, int cut1)
          Splice the given chromosomes into this using the given cut index.
 void splice(IChromosome c1, IChromosome c2, int cut)
          Splice the given chromosomes into this using the given cut index.
 String toString()
          Return a string representation of this object.
 
Methods inherited from class org.vizzini.ai.geneticalgorithm.AbstractChromosome
addFitness, compareTo, copy, equals, getDescription, getFitness, hashCode, isFitnessUnknown, mix, setDescription, setFitness, setFitnessUnknown
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.vizzini.ai.geneticalgorithm.IChromosome
addFitness, copy, equals, getDescription, getFitness, isFitnessUnknown, mix, setDescription, setFitness, setFitnessUnknown
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

AbstractChromosomeGP

public AbstractChromosomeGP()
Construct this object.

Since:
v0.3

AbstractChromosomeGP

public AbstractChromosomeGP(IFunction function)
Construct this object with the given parameter.

Parameters:
function - Function.
Since:
v0.3
Method Detail

clone

public Object clone()
Return a clone of this instance.

Specified by:
clone in interface IChromosome
Overrides:
clone in class AbstractChromosome
Since:
v0.3

evaluate

public Object evaluate(IContext context)
Evaluate this function.

Specified by:
evaluate in interface IChromosomeGP
Parameters:
context - Context in which to evaluate.
Since:
v0.3

getFunction

public IFunction getFunction()
Specified by:
getFunction in interface IChromosomeGP
Returns:
Return function.
Since:
v0.3

mix

public void mix(IChromosome c1,
                IChromosome c2,
                boolean[] mask)
Mix the genes of the given chromosomes into this using the given mask.

Specified by:
mix in interface IChromosome
Since:
v0.3

mutate

public void mutate(double mutationRate,
                   double mutationMagnitude)
Mutate this chromosome's genes using the given parameters.

Specified by:
mutate in interface IChromosome
Parameters:
mutationRate - Probability of a gene being mutated.
mutationMagnitude - The maximum allowed magnitude of the mutation.
Since:
v0.3

randomlyInitialize

public void randomlyInitialize()
Initialize the genes with random values. In genetic programming, a chromosome's function is created by a IFunctionGenerator, so this method does nothing.

Specified by:
randomlyInitialize in interface IChromosome
Since:
v0.3

setFunction

public void setFunction(IFunction function)
Specified by:
setFunction in interface IChromosomeGP
Parameters:
function - the function to set
Since:
v0.3

size

public int size()
Return the number of genes.

Specified by:
size in interface IChromosome
Since:
v0.3

splice

public void splice(IChromosome c1,
                   IChromosome c2,
                   int cut)
Splice the given chromosomes into this using the given cut index.

Specified by:
splice in interface IChromosome
Since:
v0.3

splice

public void splice(IChromosomeGP chromosome0,
                   IChromosomeGP chromosome1,
                   int cut0,
                   int cut1)
Splice the given chromosomes into this using the given cut index.

Specified by:
splice in interface IChromosomeGP
Since:
v0.3

toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class AbstractChromosome
Since:
v0.3


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02