org.artoflife.gp.genome.numeric
Class FloatGene

java.lang.Object
  |
  +--org.artoflife.gp.genome.GpTreeNode
        |
        +--org.artoflife.gp.genome.numeric.FloatGene
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class FloatGene
extends GpTreeNode

Represents a float value with some min and max value. Evaluates between -1 and 1 in this base class, but override getMin and getMax to change the type of Number this represents (may also need to configure FloatGaussianRangeMutator).

Author:
Steve Meyfroidt
See Also:
Serialized Form

Field Summary
protected  java.lang.Number value
           
 
Constructor Summary
FloatGene()
           
 
Method Summary
 java.lang.Object clone()
          Override to clone the Number value field.
 java.lang.Object evaluate(Phenotype phenotype)
          Evaluate this expression in the context of the passed Phenotype.
 java.lang.Number getMax()
          Note this is called from the constructor to initialise the value.
 java.lang.Number getMin()
          Note this is called from the constructor to initialise the value.
protected  java.util.SortedMap getMutators()
          Provides a SortedMap of GpMutators with their probabilities (Doubles between 0.0 and 1.0) so that #mutate(float) can choose one to do a mutation.
protected  java.util.List getParameterClasses()
           
 GpTreeNode getParameterGene(int index)
           
 java.lang.Class getReturnClass()
           
 java.lang.Number getValue()
           
 void setParameterGene(int index, GpTreeNode gene)
           
 void setValue(java.lang.Number value)
           
 java.lang.String toString()
           
 
Methods inherited from class org.artoflife.gp.genome.GpTreeNode
getParameterClass, getParametersLength, getSize, mutate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected java.lang.Number value
Constructor Detail

FloatGene

public FloatGene()
Method Detail

getReturnClass

public java.lang.Class getReturnClass()
Specified by:
getReturnClass in class GpTreeNode
Returns:
the class this gene returns on evaluation

getMin

public java.lang.Number getMin()
Note this is called from the constructor to initialise the value.


getMax

public java.lang.Number getMax()
Note this is called from the constructor to initialise the value.


setValue

public final void setValue(java.lang.Number value)

getValue

public java.lang.Number getValue()

evaluate

public java.lang.Object evaluate(Phenotype phenotype)
Description copied from class: GpTreeNode
Evaluate this expression in the context of the passed Phenotype.

Specified by:
evaluate in class GpTreeNode

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getMutators

protected java.util.SortedMap getMutators()
Description copied from class: GpTreeNode
Provides a SortedMap of GpMutators with their probabilities (Doubles between 0.0 and 1.0) so that #mutate(float) can choose one to do a mutation. The map needs to look like:
0.1
a GpMutator instance with 10% chance of being used
0.2
a different GpMutator instance with 10% chance of being used
1.0
a GpMutator instance with 80% chance of being used

Load from configuration properties. [getClass().getName()].mutator.class.0 and optionally [getClass().getName()].mutator.probability.0 using: Configuration.getInstance().getInstancesProbabilities(getClass().getName() + ".mutator");

Overrides:
getMutators in class GpTreeNode
Returns:
SortedMap of probability vs mutator class, or null if no mutators for this gene
See Also:
GpTreeNode.getMutators()

getParameterClasses

protected java.util.List getParameterClasses()
Specified by:
getParameterClasses in class GpTreeNode
Returns:
List of the Classes that this gene expects to evaluate against
See Also:
GpTreeNode.getParameterClasses()

getParameterGene

public GpTreeNode getParameterGene(int index)
Specified by:
getParameterGene in class GpTreeNode
Returns:
the gene at the passed index, may be null
See Also:
GpTreeNode.getParameterGene(int)

setParameterGene

public void setParameterGene(int index,
                             GpTreeNode gene)
Specified by:
setParameterGene in class GpTreeNode
Parameters:
index - the index of the gene to replace
gene - the gene to replace with
See Also:
GpTreeNode.setParameterGene(int, GpTreeNode)

clone

public java.lang.Object clone()
Override to clone the Number value field.

Overrides:
clone in class GpTreeNode

artoflife pre0.1.0-dev

Copyright © 2002 the Art Of Life team. All Rights Reserved.