com.groovyj.jgprog.functions
Class ADF

java.lang.Object
  |
  +--com.groovyj.jgprog.Function
        |
        +--com.groovyj.jgprog.functions.ADF
All Implemented Interfaces:
java.io.Serializable

public class ADF
extends Function
implements java.io.Serializable

An automatically defined function (ADF) is a chromosome which takes a number of arguments. Calling an ADF results in setting the arguments and computing the value of the chromosome.

Copyright (c) 2000 Robert Baruch. This code is released under the GNU General Public License (GPL).

Version:
$Id: ADF.java,v 1.1 2000/10/12 15:19:39 groovyjava Exp $
Author:
Robert Baruch (jgprog@sourceforge.net)
See Also:
Serialized Form

Field Summary
 int chromosomeNum
           
 
Fields inherited from class com.groovyj.jgprog.Function
arity, individual, returnType
 
Constructor Summary
ADF(int chromosomeNum, Type[] argTypes)
          Creates an ADF node which will evaluate the given chromosome number and takes the given argument types.
 
Method Summary
 boolean execute_boolean(Chromosome c, int n)
          Executes this node as a boolean.
 double execute_double(Chromosome c, int n)
          Executes this node as a double.
 float execute_float(Chromosome c, int n)
          Executes this node as a float.
 int execute_int(Chromosome c, int n)
          Executes this node as an integer.
 long execute_long(Chromosome c, int n)
          Executes this node as a long.
 java.lang.Object execute_object(Chromosome c, int n)
          Executes this node as an object.
 void execute_void(Chromosome c, int n)
          Executes this node, returning nothing.
 Type getChildType(int i)
          Gets the type of node allowed form the given child number.
 int getChromosomeNum()
          Get the chromosome number this ADF refers to.
 java.lang.String getName()
          Gets the name of this node.
 boolean isConstant()
           
 
Methods inherited from class com.groovyj.jgprog.Function
execute, getArity, getReturnType, setIndividual, setReturnType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

chromosomeNum

public int chromosomeNum
Constructor Detail

ADF

public ADF(int chromosomeNum,
           Type[] argTypes)
Creates an ADF node which will evaluate the given chromosome number and takes the given argument types.
Parameters:
chromosomeNum - the chromosome number to evaluate
argTypes - the types for the arguments
Since:
1.0
Method Detail

getName

public java.lang.String getName()
Description copied from class: Function
Gets the name of this node. Must be overridden in subclasses.
Overrides:
getName in class Function
Following copied from class: com.groovyj.jgprog.Function
Returns:
the name of this node.

getChromosomeNum

public int getChromosomeNum()
Get the chromosome number this ADF refers to.
Returns:
the chromosome number this ADF refers to.
Since:
1.0

execute_boolean

public boolean execute_boolean(Chromosome c,
                               int n)
Description copied from class: Function
Executes this node as a boolean.
Overrides:
execute_boolean in class Function
Following copied from class: com.groovyj.jgprog.Function
Returns:
the boolean return value of this node
Throws:
UnsupportedOperationException - if the type of this node is not boolean

execute_void

public void execute_void(Chromosome c,
                         int n)
Description copied from class: Function
Executes this node, returning nothing.
Overrides:
execute_void in class Function
Following copied from class: com.groovyj.jgprog.Function
Throws:
UnsupportedOperationException - if the type of this node is not void

execute_int

public int execute_int(Chromosome c,
                       int n)
Description copied from class: Function
Executes this node as an integer.
Overrides:
execute_int in class Function
Following copied from class: com.groovyj.jgprog.Function
Returns:
the integer return value of this node
Throws:
UnsupportedOperationException - if the type of this node is not integer

execute_long

public long execute_long(Chromosome c,
                         int n)
Description copied from class: Function
Executes this node as a long.
Overrides:
execute_long in class Function
Following copied from class: com.groovyj.jgprog.Function
Returns:
the long return value of this node
Throws:
UnsupportedOperationException - if the type of this node is not long

execute_float

public float execute_float(Chromosome c,
                           int n)
Description copied from class: Function
Executes this node as a float.
Overrides:
execute_float in class Function
Following copied from class: com.groovyj.jgprog.Function
Returns:
the float return value of this node
Throws:
UnsupportedOperationException - if the type of this node is not float

execute_object

public java.lang.Object execute_object(Chromosome c,
                                       int n)
Description copied from class: Function
Executes this node as an object.
Overrides:
execute_object in class Function
Following copied from class: com.groovyj.jgprog.Function
Returns:
the object return value of this node
Throws:
UnsupportedOperationException - if the type of this node is not object

execute_double

public double execute_double(Chromosome c,
                             int n)
Description copied from class: Function
Executes this node as a double.
Overrides:
execute_double in class Function
Following copied from class: com.groovyj.jgprog.Function
Returns:
the double return value of this node
Throws:
UnsupportedOperationException - if the type of this node is not double

getChildType

public Type getChildType(int i)
Description copied from class: Function
Gets the type of node allowed form the given child number. Must be overridden in subclasses.
Overrides:
getChildType in class Function
Following copied from class: com.groovyj.jgprog.Function
Parameters:
i - the child number
Returns:
the type of node allowed for that child

isConstant

public boolean isConstant()