JGAP

org.jgap.gp.terminal
Class Terminal

java.lang.Object
  extended by org.jgap.gp.CommandGene
      extended by org.jgap.gp.terminal.Terminal
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, IMutateable

public class Terminal
extends CommandGene
implements IMutateable

A terminal is a static number that can be mutated.

Since:
3.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jgap.gp.CommandGene
BooleanClass, DELTA, DoubleClass, FloatClass, IntegerClass, LongClass, VoidClass
 
Constructor Summary
Terminal()
           
Terminal(GPConfiguration a_conf, java.lang.Class a_returnType)
           
Terminal(GPConfiguration a_conf, java.lang.Class a_returnType, double a_minValue, double a_maxValue)
           
 
Method Summary
 CommandGene applyMutation(int index, double a_percentage)
          Mutates a CommandGene
 double execute_double(ProgramChromosome c, int n, java.lang.Object[] args)
          Executes this node as a double.
 float execute_float(ProgramChromosome c, int n, java.lang.Object[] args)
          Executes this node as a float.
 int execute_int(ProgramChromosome c, int n, java.lang.Object[] args)
          Executes this node as an integer.
 long execute_long(ProgramChromosome c, int n, java.lang.Object[] args)
          Executes this node as a long.
 java.lang.Class getChildType(IGPProgram a_ind, int a_chromNum)
          Gets the type of node allowed form the given child number.
protected  void setRandomValue()
           
protected  void setRandomValue(double a_value)
           
protected  void setRandomValue(float a_value)
           
protected  void setRandomValue(int a_value)
           
protected  void setRandomValue(long a_value)
           
 void setValue(double a_value)
           
 void setValue(float a_value)
           
 void setValue(int a_value)
           
 void setValue(long a_value)
           
 java.lang.String toString()
           
 
Methods inherited from class org.jgap.gp.CommandGene
check, check, cleanup, compareTo, equals, execute_boolean, execute_object, execute_void, execute, getAllele, getApplicationData, getArity, getEnergy, getGPConfiguration, getInternalValue, getName, getPersistentRepresentation, getReturnType, hashCode, init, isAffectGlobalState, isCompareApplicationData, isFloatType, isIntegerType, isValid, isValid, setAllele, setApplicationData, setCompareApplicationData, setEnergy, setNoValidation, setReturnType, setToRandomValue, setValueFromPersistentRepresentation, size
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Terminal

public Terminal()
         throws InvalidConfigurationException
Throws:
InvalidConfigurationException

Terminal

public Terminal(GPConfiguration a_conf,
                java.lang.Class a_returnType)
         throws InvalidConfigurationException
Throws:
InvalidConfigurationException

Terminal

public Terminal(GPConfiguration a_conf,
                java.lang.Class a_returnType,
                double a_minValue,
                double a_maxValue)
         throws InvalidConfigurationException
Throws:
InvalidConfigurationException
Method Detail

setRandomValue

protected void setRandomValue(int a_value)

setRandomValue

protected void setRandomValue(long a_value)

setRandomValue

protected void setRandomValue(double a_value)

setRandomValue

protected void setRandomValue(float a_value)

setRandomValue

protected void setRandomValue()

setValue

public void setValue(double a_value)

setValue

public void setValue(float a_value)

setValue

public void setValue(int a_value)

setValue

public void setValue(long a_value)

applyMutation

public CommandGene applyMutation(int index,
                                 double a_percentage)
                          throws InvalidConfigurationException
Description copied from interface: IMutateable
Mutates a CommandGene

Specified by:
applyMutation in interface IMutateable
Parameters:
index - references the part of a multipart object, normally not relevant
a_percentage - the mutation rate (0.0 to 1.0)
Returns:
the mutant
Throws:
InvalidConfigurationException

toString

public java.lang.String toString()
Specified by:
toString in class CommandGene
Returns:
the string representation of the command. Especially usefull to output a resulting formula in human-readable form.

execute_int

public int execute_int(ProgramChromosome c,
                       int n,
                       java.lang.Object[] args)
Description copied from class: CommandGene
Executes this node as an integer. Override to implement.

Overrides:
execute_int in class CommandGene
Parameters:
c - ignored here
n - ignored here
args - ignored here
Returns:
nothing but exception

execute_long

public long execute_long(ProgramChromosome c,
                         int n,
                         java.lang.Object[] args)
Description copied from class: CommandGene
Executes this node as a long. Override to implement.

Overrides:
execute_long in class CommandGene
Parameters:
c - ignored here
n - ignored here
args - ignored here
Returns:
nothing but exception

execute_float

public float execute_float(ProgramChromosome c,
                           int n,
                           java.lang.Object[] args)
Description copied from class: CommandGene
Executes this node as a float. Override to implement.

Overrides:
execute_float in class CommandGene
Parameters:
c - ignored here
n - ignored here
args - ignored here
Returns:
nothing but exception

execute_double

public double execute_double(ProgramChromosome c,
                             int n,
                             java.lang.Object[] args)
Description copied from class: CommandGene
Executes this node as a double. Override to implement.

Overrides:
execute_double in class CommandGene
Parameters:
c - ignored here
n - ignored here
args - ignored here
Returns:
nothing but exception

getChildType

public java.lang.Class getChildType(IGPProgram a_ind,
                                    int a_chromNum)
Description copied from class: CommandGene
Gets the type of node allowed form the given child number. Must be overridden in subclasses.

Overrides:
getChildType in class CommandGene
Parameters:
a_ind - the individual the child belongs to
a_chromNum - the chromosome number
Returns:
the type of node allowed for that child

JGAP