org.jgap.gp
Class BaseGPChromosome
- java.lang.Object
-
- org.jgap.gp.BaseGPChromosome
-
- All Implemented Interfaces:
- java.io.Serializable, IGPChromosome
- Direct Known Subclasses:
- ProgramChromosome
public abstract class BaseGPChromosome extends java.lang.Object implements IGPChromosome
Abstract base class for all implementations of IGPChromosome.- Since:
- 3.01
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description BaseGPChromosome(GPConfiguration a_configuration)BaseGPChromosome(GPConfiguration a_configuration, IGPProgram a_ind)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intgetAssignableFromClass(int a_n, java.lang.Class a_class)Helper: Find GP command being assignable from given class.intgetCommandOfClass(int a_n, java.lang.Class a_class)Helper: Find GP command with given class and return index of it.intgetFunction(int a_index)Gets the a_index'th function in this chromosome.intgetFunction(int a_index, java.lang.Class a_type, int a_subType)Gets the i'th function of the given return type in this chromosome.GPConfigurationgetGPConfiguration()IGPProgramgetIndividual()CommandGenegetNode(int a_index)Gets the a_index'th node in this chromosome.intgetTerminal(int a_index)Gets the i'th terminal in this chromosome.intgetTerminal(int a_index, java.lang.Class a_type, int a_subType)Gets the a_index'th terminal of the given type in this chromosome.intgetVariableWithReturnType(int a_n, java.lang.Class a_returnType)Helper: Find GP Variable with given return type and return index of it.intnumFunctions()intnumFunctions(java.lang.Class a_type, int a_subType)Counts the number of functions of the given type in this chromosome.intnumTerminals()intnumTerminals(java.lang.Class a_type, int a_subType)Counts the number of terminals of the given type in this chromosome.voidsetIndividual(IGPProgram a_ind)Sets the individual the chromosome belongs to.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jgap.gp.IGPChromosome
cleanup, getChild, getFunctions, getFunctionSet, getPersistentRepresentation, redepth, toStringNorm
-
-
-
-
Constructor Detail
-
BaseGPChromosome
public BaseGPChromosome(GPConfiguration a_configuration) throws InvalidConfigurationException
- Throws:
InvalidConfigurationException
-
BaseGPChromosome
public BaseGPChromosome(GPConfiguration a_configuration, IGPProgram a_ind) throws InvalidConfigurationException
- Throws:
InvalidConfigurationException
-
-
Method Detail
-
getIndividual
public IGPProgram getIndividual()
- Specified by:
getIndividualin interfaceIGPChromosome- Returns:
- the individual containing this chromosome
- Since:
- 3.01 (since 3.0 in ProgramChromosome)
-
setIndividual
public void setIndividual(IGPProgram a_ind)
Sets the individual the chromosome belongs to.- Specified by:
setIndividualin interfaceIGPChromosome- Parameters:
a_ind- the individual containing this chromosome- Since:
- 3.01 (since 3.0 in ProgramChromosome)
-
getTerminal
public int getTerminal(int a_index)
Gets the i'th terminal in this chromosome. The nodes are counted in a depth-first manner, with node zero being the first terminal in this chromosome.- Specified by:
getTerminalin interfaceIGPChromosome- Parameters:
a_index- the i'th terminal to get- Returns:
- the terminal
- Since:
- 3.01 (since 3.0 in ProgramChromosome)
-
getFunction
public int getFunction(int a_index)
Gets the a_index'th function in this chromosome. The nodes are counted in a depth-first manner, with node zero being the first function in this chromosome.- Specified by:
getFunctionin interfaceIGPChromosome- Parameters:
a_index- the a_index'th function to get- Returns:
- the function
- Since:
- 3.01 (since 3.0 in ProgramChromosome)
-
getTerminal
public int getTerminal(int a_index, java.lang.Class a_type, int a_subType)Gets the a_index'th terminal of the given type in this chromosome. The nodes are counted in a depth-first manner, with node zero being the first terminal of the given type in this chromosome.- Specified by:
getTerminalin interfaceIGPChromosome- Parameters:
a_index- the a_index'th terminal to geta_type- the type of terminal to geta_subType- the subtype to consider- Returns:
- the index of the terminal found, or -1 if no appropriate terminal was found
- Since:
- 3.01 (since 3.0 in ProgramChromosome)
-
getFunction
public int getFunction(int a_index, java.lang.Class a_type, int a_subType)Gets the i'th function of the given return type in this chromosome. The nodes are counted in a depth-first manner, with node zero being the first function of the given type in this chromosome.- Specified by:
getFunctionin interfaceIGPChromosome- Parameters:
a_index- the i'th function to geta_type- the type of function to geta_subType- the subtype to consider- Returns:
- the index of the function found, or -1 if no appropriate function was found
- Since:
- 3.01 (since 3.0 in ProgramChromosome)
-
numTerminals
public int numTerminals()
- Specified by:
numTerminalsin interfaceIGPChromosome- Returns:
- the number of terminals in this chromosome
- Since:
- 3.0
-
numFunctions
public int numFunctions()
- Specified by:
numFunctionsin interfaceIGPChromosome- Returns:
- the number of functions in this chromosome
- Since:
- 3.0
-
numTerminals
public int numTerminals(java.lang.Class a_type, int a_subType)Counts the number of terminals of the given type in this chromosome.- Specified by:
numTerminalsin interfaceIGPChromosome- Parameters:
a_type- the type of terminal to counta_subType- the subtype to consider- Returns:
- the number of terminals in this chromosome
- Since:
- 3.01 (since 3.0 in ProgramChromosome)
-
numFunctions
public int numFunctions(java.lang.Class a_type, int a_subType)Counts the number of functions of the given type in this chromosome.- Specified by:
numFunctionsin interfaceIGPChromosome- Parameters:
a_type- the type of function to counta_subType- the subtype to consider- Returns:
- the number of functions in this chromosome.
- Since:
- 3.01 (since 3.0 in ProgramChromosome)
-
getNode
public CommandGene getNode(int a_index)
Gets the a_index'th node in this chromosome. The nodes are counted in a depth-first manner, with node zero being the root of this chromosome.- Specified by:
getNodein interfaceIGPChromosome- Parameters:
a_index- the node number to get- Returns:
- the node
- Since:
- 3.01
-
getCommandOfClass
public int getCommandOfClass(int a_n, java.lang.Class a_class)Helper: Find GP command with given class and return index of it.- Parameters:
a_n- return the n'th found command (starting at zero)a_class- the class to find a command for- Returns:
- index of first found matching GP command, or -1 if none found
- Since:
- 3.01
-
getAssignableFromClass
public int getAssignableFromClass(int a_n, java.lang.Class a_class)Helper: Find GP command being assignable from given class.- Parameters:
a_n- return the n'th found command (starting at zero)a_class- the class to find a command for- Returns:
- index of first found matching GP command, or -1 if none found
- Since:
- 3.3
-
getVariableWithReturnType
public int getVariableWithReturnType(int a_n, java.lang.Class a_returnType)Helper: Find GP Variable with given return type and return index of it.- Parameters:
a_n- return the n'th found command (starting at zero)a_returnType- the return type to find a Variable for- Returns:
- index of first found matching GP command, or -1 if none found
- Since:
- 3.01 (since 3.0 in ProgramChromosome)
-
getGPConfiguration
public GPConfiguration getGPConfiguration()
- Specified by:
getGPConfigurationin interfaceIGPChromosome
-
-
DMelt 3.0 © DataMelt by jWork.ORG