gpsys.primitives
Class ProgN

java.lang.Object
  |
  +--gpsys.Primitive
        |
        +--gpsys.Function
              |
              +--gpsys.primitives.ProgN

public class ProgN
extends Function

	<typeX> ProgN(<typeX> a1, <typeX> a2, ..., <typeX> aN)
 
ProgN is a generic function that takes N arguments of the same type, evaluates all of them, and returns the value of the last argument. Supported Types include OBJECT, BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, CHAR and BOOLEAN.

Version:
$Revision: 1.1 $, $Date: 2000/07/05 16:24:33 $
Author:
Adil Qureshi
Department of Computer Science,
University College London,
Gower St,
London WC1E 6BT,
UK.
See Also:
Type, Primitive, Function, Serialized Form

Fields inherited from class gpsys.Function
argTypes
 
Fields inherited from class gpsys.Primitive
type
 
Constructor Summary
ProgN(Type returnType, int argNum)
          Constructs a new ProgN Function which takes the specified number of arguments, all of which are of the specified type.
 
Method Summary
 boolean evaluateBoolean(Individual i, Gene[] arguments)
          Used to evaluate a ProgN Function of Type BOOLEAN.
 byte evaluateByte(Individual i, Gene[] arguments)
          Used to evaluate a ProgN Function of Type BYTE.
 char evaluateChar(Individual i, Gene[] arguments)
          Used to evaluate a ProgN Function of Type CHAR.
 double evaluateDouble(Individual i, Gene[] arguments)
          Used to evaluate a ProgN Function of Type DOUBLE.
 float evaluateFloat(Individual i, Gene[] arguments)
          Used to evaluate a ProgN Function of Type FLOAT.
 int evaluateInt(Individual i, Gene[] arguments)
          Used to evaluate a ProgN Function of Type INT.
 long evaluateLong(Individual i, Gene[] arguments)
          Used to evaluate a ProgN Function of Type LONG.
 java.lang.Object evaluateObject(Individual i, Gene[] arguments)
          Used to evaluate a ProgN Function of Type OBJECT.
 short evaluateShort(Individual i, Gene[] arguments)
          Used to evaluate a ProgN Function of Type SHORT.
 Primitive instance()
          Creates an instance of this ProgN object.
 java.lang.String toString()
          Returns a String representation of this Function.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Constructor Detail

ProgN

public ProgN(Type returnType,
             int argNum)
Constructs a new ProgN Function which takes the specified number of arguments, all of which are of the specified type.
Parameters:
returnType - The type of all the arguments. This must be one one of OBJECT, BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, CHAR or BOOLEAN.
argNum - The number of arguments taken by the Function.
Method Detail

evaluateObject

public final java.lang.Object evaluateObject(Individual i,
                                             Gene[] arguments)
                                      throws EvaluationException
Used to evaluate a ProgN Function of Type OBJECT.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be evaluated.
Returns:
An Object reference, which is the value of the last argument.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateObject in class Function

evaluateByte

public final byte evaluateByte(Individual i,
                               Gene[] arguments)
                        throws EvaluationException
Used to evaluate a ProgN Function of Type BYTE.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be evaluated.
Returns:
A byte, which is the value of the last argument.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateByte in class Function

evaluateShort

public final short evaluateShort(Individual i,
                                 Gene[] arguments)
                          throws EvaluationException
Used to evaluate a ProgN Function of Type SHORT.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be evaluated.
Returns:
A short, which is the value of the last argument.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateShort in class Function

evaluateInt

public final int evaluateInt(Individual i,
                             Gene[] arguments)
                      throws EvaluationException
Used to evaluate a ProgN Function of Type INT.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be evaluated.
Returns:
An int, which is the value of the last argument.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateInt in class Function

evaluateLong

public final long evaluateLong(Individual i,
                               Gene[] arguments)
                        throws EvaluationException
Used to evaluate a ProgN Function of Type LONG.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be evaluated.
Returns:
A long, which is the value of the last argument.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateLong in class Function

evaluateFloat

public final float evaluateFloat(Individual i,
                                 Gene[] arguments)
                          throws EvaluationException
Used to evaluate a ProgN Function of Type FLOAT.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be evaluated.
Returns:
A float, which is the value of the last argument.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateFloat in class Function

evaluateDouble

public final double evaluateDouble(Individual i,
                                   Gene[] arguments)
                            throws EvaluationException
Used to evaluate a ProgN Function of Type DOUBLE.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be evaluated.
Returns:
A double, which is the value of the last argument.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateDouble in class Function

evaluateChar

public final char evaluateChar(Individual i,
                               Gene[] arguments)
                        throws EvaluationException
Used to evaluate a ProgN Function of Type CHAR.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be evaluated.
Returns:
A char, which is the value of the last argument.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateChar in class Function

evaluateBoolean

public final boolean evaluateBoolean(Individual i,
                                     Gene[] arguments)
                              throws EvaluationException
Used to evaluate a ProgN Function of Type BOOLEAN.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be evaluated.
Returns:
A boolean, which is the value of the last argument.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateBoolean in class Function

instance

public final Primitive instance()
Creates an instance of this ProgN object. The Type instantiation is preserved so that if an INT ProgN is being cloned, the clone will also be INT instantiated. So to is the number of arguments to expected (the value of N).
Returns:
A reference to this Object (yes the same object, since the type and argument information is to be the same, there are therefore no instance variables to be modified.
Overrides:
instance in class Primitive

toString

public java.lang.String toString()
Returns a String representation of this Function.
Returns:
A String containing the name of the Function.
Overrides:
toString in class Primitive