org.jgap.gp.terminal
Class Variable
- java.lang.Object
-
- org.jgap.gp.CommandGene
-
- org.jgap.gp.terminal.Variable
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Comparable
public class Variable extends CommandGene
A terminal represented by a variable (x, y, z...). A variable has one single value with can be influenced from outside.- 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 Modifier and Type Field and Description static java.util.Hashtablevars-
Fields inherited from class org.jgap.gp.CommandGene
BooleanClass, CharacterClass, DELTA, DoubleClass, FloatClass, IntegerClass, LongClass, nodeIndex, VoidClass
-
-
Constructor Summary
Constructors Constructor and Description Variable(GPConfiguration a_conf, java.lang.String a_varName, java.lang.Class a_type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static Variablecreate(GPConfiguration a_conf, java.lang.String a_name, java.lang.Class a_type)Creates an instance of a Variable.booleanexecute_boolean(ProgramChromosome c, int n, java.lang.Object[] args)Executes this node as a boolean.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)Executes this node as an object.java.lang.ClassgetChildType(IGPProgram a_ind, int a_chromNum)Gets the type of node allowed from the given child number.java.lang.StringgetName()Attention: It is important to return m_name here (see GPGenotype.putVariable).java.lang.ObjectgetValue()static VariablegetVariable(java.lang.String name)Gets the one instance of a named variable.voidset(java.lang.Object a_value)Sets the value of this named variable.java.lang.StringtoString()-
Methods inherited from class org.jgap.gp.CommandGene
cleanup, compareTo, dynamizeArity, ensureUniqueness, ensureUniqueness, ensureUniqueness2, equals, execute_void, execute, getAllele, getApplicationData, getArity, getEnergy, getGPConfiguration, getPersistentRepresentation, getReturnType, getSubChildType, getSubChildTypes, getSubReturnType, hashCode, isAffectGlobalState, isCompareApplicationData, isFloatType, isIntegerType, isValid, isValid, setAllele, setApplicationData, setCompareApplicationData, setEnergy, setNoValidation, setReturnType, setToRandomValue, setValueFromPersistentRepresentation, size
-
-
-
-
Constructor Detail
-
Variable
public Variable(GPConfiguration a_conf, java.lang.String a_varName, java.lang.Class a_type) throws InvalidConfigurationException
- Throws:
InvalidConfigurationException
-
-
Method Detail
-
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.
-
getName
public java.lang.String getName()
Attention: It is important to return m_name here (see GPGenotype.putVariable).- Overrides:
getNamein classCommandGene- Returns:
- textual name of this command
- 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
-
execute_boolean
public boolean execute_boolean(ProgramChromosome c, int n, java.lang.Object[] args)
Description copied from class:CommandGeneExecutes this node as a boolean. Override to implement.- Overrides:
execute_booleanin classCommandGene- Parameters:
c- ignored heren- ignored hereargs- ignored here- Returns:
- nothing but exception
-
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)
Description copied from class:CommandGeneExecutes this node as an object. Override to implement.- Overrides:
execute_objectin classCommandGene- Parameters:
c- ignored heren- ignored hereargs- ignored here- Returns:
- nothing but exception
-
getVariable
public static Variable getVariable(java.lang.String name)
Gets the one instance of a named variable.- Parameters:
name- the name of the variable to get- Returns:
- the named variable, or null if that name wasn't found.
- Since:
- 3.0
-
create
public static Variable create(GPConfiguration a_conf, java.lang.String a_name, java.lang.Class a_type) throws InvalidConfigurationException
Creates an instance of a Variable. If a Variable of that name already exists, that is returned. Otherwise a new instance is created, its value is initialized to null, and it is placed into the static hashtable for later retrieval by name via getVariable.- Parameters:
a_conf- the configuration to usea_name- the name of the Variable to createa_type- the type of the Variable to create- Returns:
- the variable object created
- Throws:
InvalidConfigurationException- Since:
- 3.0
-
set
public void set(java.lang.Object a_value)
Sets the value of this named variable.- Parameters:
a_value- the value to set this variable with- Since:
- 3.0
-
getValue
public java.lang.Object getValue()
-
-
DMelt 3.0 © DataMelt by jWork.ORG