org.jgap.gp.terminal
Class Terminal
- java.lang.Object
-
- org.jgap.gp.CommandGene
-
- org.jgap.gp.terminal.Terminal
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, IMutateable, ICloneable
public class Terminal extends CommandGene implements IMutateable, ICloneable
A terminal is a static number that can be mutated.- Since:
- 3.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jgap.gp.CommandGene
CommandGene.COMMAND_TYPE
-
-
Field Summary
-
Fields inherited from class org.jgap.gp.CommandGene
BooleanClass, CharacterClass, DELTA, DoubleClass, FloatClass, IntegerClass, LongClass, nodeIndex, VoidClass
-
-
Constructor Summary
Constructors Constructor and Description 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)Constructor.Terminal(GPConfiguration a_conf, java.lang.Class a_returnType, double a_minValue, double a_maxValue, boolean a_wholeNumbers)Constructor.Terminal(GPConfiguration a_conf, java.lang.Class a_returnType, double a_minValue, double a_maxValue, boolean a_wholeNumbers, int a_subReturnType)Terminal(GPConfiguration a_conf, java.lang.Class a_returnType, double a_minValue, double a_maxValue, boolean a_wholeNumbers, int a_subReturnType, boolean a_randomize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description CommandGeneapplyMutation(int index, double a_percentage)Mutates a CommandGene.java.lang.Objectclone()Clones the object.doubleexecute_double(ProgramChromosome c, int n, java.lang.Object[] args)Executes this node as a double.floatexecute_float(ProgramChromosome c, int n, java.lang.Object[] args)Executes this node as a float.intexecute_int(ProgramChromosome c, int n, java.lang.Object[] args)Executes this node as an integer.longexecute_long(ProgramChromosome c, int n, java.lang.Object[] args)Executes this node as a long.java.lang.Objectexecute_object(ProgramChromosome c, int n, java.lang.Object[] args)Returns a string representation of the terminal.java.lang.ClassgetChildType(IGPProgram a_ind, int a_chromNum)Gets the type of node allowed from the given child number.voidsetValue(double a_value)voidsetValue(float a_value)voidsetValue(int a_value)voidsetValue(long a_value)java.lang.StringtoString()-
Methods inherited from class org.jgap.gp.CommandGene
cleanup, compareTo, dynamizeArity, ensureUniqueness, ensureUniqueness, ensureUniqueness2, equals, execute_boolean, execute_void, execute, getAllele, getApplicationData, getArity, getEnergy, getGPConfiguration, getName, getPersistentRepresentation, getReturnType, getSubChildType, getSubChildTypes, getSubReturnType, hashCode, isAffectGlobalState, isCompareApplicationData, isFloatType, isIntegerType, isValid, isValid, setAllele, setApplicationData, setCompareApplicationData, setEnergy, setNoValidation, setReturnType, setToRandomValue, setValueFromPersistentRepresentation, size
-
-
-
-
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
Constructor.- Parameters:
a_conf- GPConfigurationa_returnType- Classa_minValue- doublea_maxValue- double- Throws:
InvalidConfigurationException- Since:
- 3.0
-
Terminal
public Terminal(GPConfiguration a_conf, java.lang.Class a_returnType, double a_minValue, double a_maxValue, boolean a_wholeNumbers) throws InvalidConfigurationException
Constructor.- Parameters:
a_conf- GPConfigurationa_returnType- Classa_minValue- doublea_maxValue- doublea_wholeNumbers- true: only return whole numbers (only relevant when using type double or float)- Throws:
InvalidConfigurationException- Since:
- 3.2
-
Terminal
public Terminal(GPConfiguration a_conf, java.lang.Class a_returnType, double a_minValue, double a_maxValue, boolean a_wholeNumbers, int a_subReturnType) throws InvalidConfigurationException
- Throws:
InvalidConfigurationException
-
Terminal
public Terminal(GPConfiguration a_conf, java.lang.Class a_returnType, double a_minValue, double a_maxValue, boolean a_wholeNumbers, int a_subReturnType, boolean a_randomize) throws InvalidConfigurationException
- Parameters:
a_conf- GPConfigurationa_returnType- Classa_minValue- doublea_maxValue- doublea_wholeNumbers- booleana_subReturnType- inta_randomize- true: randomize initial value- Throws:
InvalidConfigurationException- Since:
- 3.4.1
-
-
Method Detail
-
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:IMutateableMutates a CommandGene.- Specified by:
applyMutationin interfaceIMutateable- Parameters:
index- references the part of a multipart object, normally not relevanta_percentage- the mutation rate (0.0 to 1.0)- Returns:
- the mutant
- Throws:
InvalidConfigurationException
-
toString
public java.lang.String toString()
- Specified by:
toStringin classCommandGene- 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:CommandGeneExecutes this node as an integer. Override to implement.- Overrides:
execute_intin classCommandGene- Parameters:
c- ignored heren- ignored hereargs- ignored here- Returns:
- nothing but exception
-
execute_long
public long execute_long(ProgramChromosome c, int n, java.lang.Object[] args)
Description copied from class:CommandGeneExecutes this node as a long. Override to implement.- Overrides:
execute_longin classCommandGene- Parameters:
c- ignored heren- ignored hereargs- ignored here- Returns:
- nothing but exception
-
execute_float
public float execute_float(ProgramChromosome c, int n, java.lang.Object[] args)
Description copied from class:CommandGeneExecutes this node as a float. Override to implement.- Overrides:
execute_floatin classCommandGene- Parameters:
c- ignored heren- ignored hereargs- ignored here- Returns:
- nothing but exception
-
execute_double
public double execute_double(ProgramChromosome c, int n, java.lang.Object[] args)
Description copied from class:CommandGeneExecutes this node as a double. Override to implement.- Overrides:
execute_doublein classCommandGene- Parameters:
c- ignored heren- ignored hereargs- ignored here- Returns:
- nothing but exception
-
execute_object
public java.lang.Object execute_object(ProgramChromosome c, int n, java.lang.Object[] args)
Returns a string representation of the terminal.- Overrides:
execute_objectin classCommandGene- Parameters:
c- ignored heren- ignored hereargs- ignored here- Returns:
- StringBuffer with textual representation of terminal's value
- Since:
- 3.2
-
getChildType
public java.lang.Class getChildType(IGPProgram a_ind, int a_chromNum)
Description copied from class:CommandGeneGets the type of node allowed from the given child number. Should be overridden in subclasses.- Overrides:
getChildTypein classCommandGene- Parameters:
a_ind- the individual the child belongs toa_chromNum- the chromosome number- Returns:
- the type of node allowed for that child, or null of no child exists
-
clone
public java.lang.Object clone()
Clones the object. Simple and straight forward implementation here.- Specified by:
clonein interfaceICloneable- Overrides:
clonein classjava.lang.Object- Returns:
- cloned instance of this object
- Since:
- 3.2
-
-
DMelt 3.0 © DataMelt by jWork.ORG