gpsys.primitives
Class MemGet

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

public class MemGet
extends Function

	<typeX> MemGet(MEM_typeX memory, INT index)
 
MemGet is a generic Function which takes two arguments. The first is an indexed memory. The second is an index into that memory. The Function retrieves the value at the specified location of the specified memory. MemGet needs to be instantiated to work with a particular type of memory. Valid memory types include MEM_OBJECT, MEM_BYTE, MEM_SHORT, MEM_INT, MEM_LONG, MEM_FLOAT, MEM_DOUBLE, MEM_CHAR, and MEM_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, Terminal, gpsys.MemSet, Serialized Form

Fields inherited from class gpsys.Function
argTypes
 
Fields inherited from class gpsys.Primitive
type
 
Constructor Summary
MemGet(Type memoryType, Type returnType)
          Construct a new MemGet Function to access the specified memory type, which holds the specified type of elements.
 
Method Summary
 boolean evaluateBoolean(Individual i, Gene[] arguments)
          Used to get values from memory of MEM_BOOLEAN type.
 byte evaluateByte(Individual i, Gene[] arguments)
          Used to get values from memory of MEM_BYTE type.
 char evaluateChar(Individual i, Gene[] arguments)
          Used to get values from memory of MEM_CHAR type.
 double evaluateDouble(Individual i, Gene[] arguments)
          Used to get values from memory of MEM_DOUBLE type.
 float evaluateFloat(Individual i, Gene[] arguments)
          Used to get values from memory of MEM_FLOAT type.
 int evaluateInt(Individual i, Gene[] arguments)
          Used to get values from memory of MEM_INT type.
 long evaluateLong(Individual i, Gene[] arguments)
          Used to get values from memory of MEM_LONG type.
 java.lang.Object evaluateObject(Individual i, Gene[] arguments)
          Used to get values from memory of MEM_OBJECT type.
 short evaluateShort(Individual i, Gene[] arguments)
          Used to get values from memory of MEM_SHORT type.
 Primitive instance()
          Creates an instance of this MemGet 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

MemGet

public MemGet(Type memoryType,
              Type returnType)
Construct a new MemGet Function to access the specified memory type, which holds the specified type of elements.
Parameters:
memoryType - The type of the memory, can be one of MEM_OBJECT, MEM_BYTE, MEM_SHORT, MEM_INT,MEM_LONG, MEM_FLOAT, MEM_DOUBLE, MEM_CHAR, and MEM_BOOLEAN.
returnType - The type that the memory holds, can be one of OBJECT, BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, CHAR, and BOOLEAN.
Method Detail

evaluateObject

public final java.lang.Object evaluateObject(Individual i,
                                             Gene[] arguments)
                                      throws EvaluationException
Used to get values from memory of MEM_OBJECT type.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees supplied as arguments to the Function, the first argument is the memory to be accessed, and the second argument is the index of the memory location being accessed.
Returns:
An Object reference representing the value of the memory at the specified location.
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 get values from memory of MEM_BYTE type.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees supplied as arguments to the Function, the first argument is the memory to be accessed, and the second argument is the index of the memory location being accessed.
Returns:
A byte representing the value of the memory at the specified location.
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 get values from memory of MEM_SHORT type.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees supplied as arguments to the Function, the first argument is the memory to be accessed, and the second argument is the index of the memory location being accessed.
Returns:
A byte representing the value of the memory at the specified location.
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 get values from memory of MEM_INT type.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees supplied as arguments to the Function, the first argument is the memory to be accessed, and the second argument is the index of the memory location being accessed.
Returns:
An int representing the value of the memory at the specified location.
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 get values from memory of MEM_LONG type.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees supplied as arguments to the Function, the first argument is the memory to be accessed, and the second argument is the index of the memory location being accessed.
Returns:
A long representing the value of the memory at the specified location.
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 get values from memory of MEM_FLOAT type.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees supplied as arguments to the Function, the first argument is the memory to be accessed, and the second argument is the index of the memory location being accessed.
Returns:
A float representing the value of the memory at the specified location.
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 get values from memory of MEM_DOUBLE type.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees supplied as arguments to the Function, the first argument is the memory to be accessed, and the second argument is the index of the memory location being accessed.
Returns:
A double representing the value of the memory at the specified location.
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 get values from memory of MEM_CHAR type.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees supplied as arguments to the Function, the first argument is the memory to be accessed, and the second argument is the index of the memory location being accessed.
Returns:
A char representing the value of the memory at the specified location.
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 get values from memory of MEM_BOOLEAN type.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees supplied as arguments to the Function, the first argument is the memory to be accessed, and the second argument is the index of the memory location being accessed.
Returns:
A boolean representing the value of the memory at the specified location.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateBoolean in class Function

instance

public final Primitive instance()
Creates an instance of this MemGet object. The Type instantiation is preserved so that if an MEM_INT MemGet is being cloned, the clone will also be MEM_INT instantiated.
Returns:
A reference to this Object (yes the same object, since the type 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