org.jgap.gp.function
Class ADF
- java.lang.Object
-
- org.jgap.gp.CommandGene
-
- org.jgap.gp.function.ADF
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Comparable
public class ADF extends CommandGene
Automatically Defined Function (ADF). Works with output of other chromosomes. An ADF is automatically created by ProgramChromosome. For more information about ADFs see John Koza's book on Genetic Programming. Or google for "Koza ADF". For a German explanation, see see http://www.tu-chemnitz.de/informatik/ThIS/seminare/ws01/gp/singer.pdf or http://www.tu-chemnitz.de/informatik/ThIS/seminare/ws01/gp/forbriger.pdf or http://www.klaus-meffert.de/download/genetische_programmierung_mit_java.pdf- 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 ADF(GPConfiguration a_conf, int a_chromosomeNum, int a_arity)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intcompareTo(java.lang.Object a_other)The compareTo-method.booleanequals(java.lang.Object a_other)The equals-method.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.java.lang.Objectexecute_object(ProgramChromosome c, int n, java.lang.Object[] args)Executes this node as an object.intgetArity(IGPProgram a_individual)Arity of the command.java.lang.ClassgetChildType(IGPProgram a_ind, int i)Gets the type of node allowed from the given child number.intgetChromosomeNum()booleanisValid(ProgramChromosome a_chrom)Subclasses capable of validating programs should overwrite this method.java.lang.StringtoString()-
Methods inherited from class org.jgap.gp.CommandGene
cleanup, dynamizeArity, ensureUniqueness, ensureUniqueness, ensureUniqueness2, execute_long, execute_void, execute, getAllele, getApplicationData, getEnergy, getGPConfiguration, getName, getPersistentRepresentation, getReturnType, getSubChildType, getSubChildTypes, getSubReturnType, hashCode, isAffectGlobalState, isCompareApplicationData, isFloatType, isIntegerType, isValid, setAllele, setApplicationData, setCompareApplicationData, setEnergy, setNoValidation, setReturnType, setToRandomValue, setValueFromPersistentRepresentation, size
-
-
-
-
Constructor Detail
-
ADF
public ADF(GPConfiguration a_conf, int a_chromosomeNum, int a_arity) throws InvalidConfigurationException
Constructor.- Parameters:
a_conf- the configuration to usea_chromosomeNum- the index of the chromosome to executea_arity- the arity of the ADF- Throws:
InvalidConfigurationException- Since:
- 3.0
-
-
Method Detail
-
getChromosomeNum
public int getChromosomeNum()
- Returns:
- the index of the chromosome to execute
- Since:
- 3.0
-
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.
-
getArity
public int getArity(IGPProgram a_individual)
Description copied from class:CommandGeneArity of the command. Override if necessary. The arity is the number of children a node has.- Overrides:
getArityin classCommandGene- Parameters:
a_individual- the invididual the command's arity may depend on (in most cases the arity will not depend on the individual)- Returns:
- arity of the command
-
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_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_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
-
getChildType
public java.lang.Class getChildType(IGPProgram a_ind, int i)
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 toi- the chromosome number- Returns:
- the type of node allowed for that child, or null of no child exists
-
isValid
public boolean isValid(ProgramChromosome a_chrom)
Description copied from class:CommandGeneSubclasses capable of validating programs should overwrite this method. See class Push as a sample.- Overrides:
isValidin classCommandGene- Parameters:
a_chrom- the ProgramChromosome to validate- Returns:
- true: a_program is (superficially) valid with the current Command
-
compareTo
public int compareTo(java.lang.Object a_other)
The compareTo-method.- Specified by:
compareToin interfacejava.lang.Comparable- Overrides:
compareToin classCommandGene- Parameters:
a_other- the other object to compare- Returns:
- -1, 0, 1
- Since:
- 3.0
-
equals
public boolean equals(java.lang.Object a_other)
The equals-method.- Overrides:
equalsin classCommandGene- Parameters:
a_other- the other object to compare- Returns:
- true if the objects are seen as equal
- Since:
- 3.0
-
-
DMelt 3.0 © DataMelt by jWork.ORG