gpsys.primitives
Class MemSet

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

public class MemSet
extends Function

	<typeX> MemSet(MEM_typeX memory, INT index, <typeX> value)
 
MemSet is a generic Function which takes three arguments. The first is an indexed memory. The second is an index into that memory. The third is the value that the specified location of the specified memory needs to be set. 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.MemGet, Serialized Form

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

MemSet

public MemSet(Type memoryType,
              Type returnType)
Construct a new MemSet Function to assign values to 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 set values in memories 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 written to, the second argument is the index of the memory location to be assigned, and third is the value to be assigned.
Returns:
An Object reference representing the new 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 set values in memories 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 written to, the second argument is the index of the memory location to be assigned, and third is the value to be assigned.
Returns:
A byte representing the new 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 set values in memories 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 written to, the second argument is the index of the memory location to be assigned, and third is the value to be assigned.
Returns:
A short representing the new 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 set values in memories 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 written to, the second argument is the index of the memory location to be assigned, and third is the value to be assigned.
Returns:
An int representing the new 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 set values in memories 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 written to, the second argument is the index of the memory location to be assigned, and third is the value to be assigned.
Returns:
A long representing the new 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 set values in memories 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 written to, the second argument is the index of the memory location to be assigned, and third is the value to be assigned.
Returns:
A float representing the new 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 set values in memories 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 written to, the second argument is the index of the memory location to be assigned, and third is the value to be assigned.
Returns:
A double representing the new 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 set values in memories 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 written to, the second argument is the index of the memory location to be assigned, and third is the value to be assigned.
Returns:
A char representing the new 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 set values in memories 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 written to, the second argument is the index of the memory location to be assigned, and third is the value to be assigned.
Returns:
A boolean representing the new 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 MemSet object. The Type instantiation is preserved so that if an MEM_INT MemSet 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