JGAP

org.jgap.gp.function
Class ADF

java.lang.Object
  extended by org.jgap.gp.CommandGene
      extended by 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
ADF(GPConfiguration a_conf, int a_chromosomeNum, int a_arity)
          Constructor.
 
Method Summary
 int compareTo(java.lang.Object a_other)
          The compareTo-method.
 boolean equals(java.lang.Object a_other)
          The equals-method.
 boolean execute_boolean(ProgramChromosome c, int n, java.lang.Object[] args)
          Executes this node as a boolean.
 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.
 java.lang.Object execute_object(ProgramChromosome c, int n, java.lang.Object[] args)
          Executes this node as an object.
 int getArity(IGPProgram a_individual)
          Arity of the command.
 java.lang.Class getChildType(IGPProgram a_ind, int i)
          Gets the type of node allowed from the given child number.
 int getChromosomeNum()
           
 boolean isValid(ProgramChromosome a_chrom)
          Subclasses capable of validating programs should overwrite this method.
 java.lang.String toString()
           
 
Methods inherited from class org.jgap.gp.CommandGene
check, check, cleanup, dynamizeArity, ensureUniqueness, ensureUniqueness, ensureUniqueness2, execute_long, execute_void, execute, getAllele, getApplicationData, getArityMax, getArityMin, getCommandType, getEnergy, getGPConfiguration, getInternalValue, getName, getPersistentRepresentation, getPersistentRepresentationExt, getReturnType, getSubChildType, getSubChildTypes, getSubReturnType, hashCode, init, isAffectGlobalState, isCompareApplicationData, isFloatType, isIntegerType, isValid, setAllele, setApplicationData, setArity, setArityMax, setArityMin, setCompareApplicationData, setEnergy, setNoValidation, setReturnType, setToRandomValue, setValueFromPersistentRepresentation, setValueFromString, size
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ADF

public ADF(GPConfiguration a_conf,
           int a_chromosomeNum,
           int a_arity)
    throws InvalidConfigurationException
Constructor.

Parameters:
a_conf - the configuration to use
a_chromosomeNum - the index of the chromosome to execute
a_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:
toString in class CommandGene
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: CommandGene
Arity of the command. Override if necessary. The arity is the number of children a node has.

Overrides:
getArity in class CommandGene
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: 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_boolean

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

Overrides:
execute_boolean 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

execute_object

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

Overrides:
execute_object 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 i)
Description copied from class: CommandGene
Gets the type of node allowed from the given child number. Should be overridden in subclasses.

Overrides:
getChildType in class CommandGene
Parameters:
a_ind - the individual the child belongs to
i - 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: CommandGene
Subclasses capable of validating programs should overwrite this method. See class Push as a sample.

Overrides:
isValid in class CommandGene
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:
compareTo in interface java.lang.Comparable
Overrides:
compareTo in class CommandGene
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:
equals in class CommandGene
Parameters:
a_other - the other object to compare
Returns:
true if the objects are seen as equal
Since:
3.0

JGAP