All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class gpsys.primitives.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.

Author:
Adil Qureshi
Department of Computer Science,
University College London,
Gower St,
London WC1E 6BT,
UK.
See Also:
Type, Primitive, Terminal, MemSet

Constructor Index

 o MemGet(Type, Type)
Construct a new MemGet Function to access the specified memory type, which holds the specified type of elements.

Method Index

 o evaluateBoolean(Individual, Gene[])
Used to get values from memory of MEM_BOOLEAN type.
 o evaluateByte(Individual, Gene[])
Used to get values from memory of MEM_BYTE type.
 o evaluateChar(Individual, Gene[])
Used to get values from memory of MEM_CHAR type.
 o evaluateDouble(Individual, Gene[])
Used to get values from memory of MEM_DOUBLE type.
 o evaluateFloat(Individual, Gene[])
Used to get values from memory of MEM_FLOAT type.
 o evaluateInt(Individual, Gene[])
Used to get values from memory of MEM_INT type.
 o evaluateLong(Individual, Gene[])
Used to get values from memory of MEM_LONG type.
 o evaluateObject(Individual, Gene[])
Used to get values from memory of MEM_OBJECT type.
 o evaluateShort(Individual, Gene[])
Used to get values from memory of MEM_SHORT type.
 o instance()
Creates an instance of this MemGet object.
 o toString()
Returns a String representation of this Function.

Constructors

 o 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.

Methods

 o evaluateObject
 public final 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o toString
 public String toString()
Returns a String representation of this Function.

Returns:
A String containing the name of the Function.
Overrides:
toString in class Primitive

All Packages  Class Hierarchy  This Package  Previous  Next  Index