All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class gpsys.primitives.If

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

public class If
extends Function
	<TypeX> if (BOOLEAN condition, <typeX> trueValue, <typeX> falseValue)
 
If is a generic function that conditionally evaluates one of two arguments. The function evaluates the first argument (which is of Type BOOLEAN). If the result is true, then the result of evaluating the second argument is returned, otherwise the result of evaluating the third argument is returned. The second and third arguments must be of the same type. If needs to be Type instantiated during construction to work with particular argument Types. The supported argument Types include BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, CHAR and BOOLEAN.

Version:
1.1, 30th June '97
Author:
Adil Qureshi
Department of Computer Science,
University College London,
Gower St,
London WC1E 6BT,
UK.
See Also:
Type, Primitive, Function

Constructor Index

 o If(Type)
Constructs an If Function that works with the specified Type.

Method Index

 o evaluateBoolean(Individual, Gene[])
Used to conditionally evaluate arguments of BOOLEAN Types.
 o evaluateByte(Individual, Gene[])
Used to conditionally evaluate arguments of BYTE Types.
 o evaluateChar(Individual, Gene[])
Used to conditionally evaluate arguments of CHAR Types.
 o evaluateDouble(Individual, Gene[])
Used to conditionally evaluate arguments of DOUBLE Types.
 o evaluateFloat(Individual, Gene[])
Used to conditionally evaluate arguments of FLOAT Types.
 o evaluateInt(Individual, Gene[])
Used to conditionally evaluate arguments of INT Types.
 o evaluateLong(Individual, Gene[])
Used to conditionally evaluate arguments of LONG Types.
 o evaluateObject(Individual, Gene[])
Used to conditionally evaluate arguments of OBJECT Types.
 o evaluateShort(Individual, Gene[])
Used to conditionally evaluate arguments of SHORT Types.
 o instance()
Creates an If Object of the same type.
 o toString()
Returns a String representation of this Function.

Constructors

 o If
 public If(Type returnType)
Constructs an If Function that works with the specified Type. The supported Types include BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, CHAR, BOOLEAN, and OBJECT.

Parameters:
type - The Type of this If Function.

Methods

 o evaluateObject
 public final Object evaluateObject(Individual i,
                                    Gene arguments[]) throws EvaluationException
Used to conditionally evaluate arguments of OBJECT Types.

Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be conditionally evaluated.
Returns:
An Object reference representing the result of the evaluation.
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 conditionally evaluate arguments of BYTE Types.

Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be conditionally evaluated.
Returns:
A byte representing the result of the evaluation.
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 conditionally evaluate arguments of SHORT Types.

Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be conditionally evaluated.
Returns:
A short representing the result of the evaluation.
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 conditionally evaluate arguments of INT Types.

Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be conditionally evaluated.
Returns:
An int representing the result of the evaluation.
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 conditionally evaluate arguments of LONG Types.

Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be conditionally evaluated.
Returns:
A long representing the result of the evaluation.
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 conditionally evaluate arguments of FLOAT Types.

Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be conditionally evaluated.
Returns:
A float representing the result of the evaluation.
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 conditionally evaluate arguments of DOUBLE Types.

Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be conditionally evaluated.
Returns:
A double representing the result of the evaluation.
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 conditionally evaluate arguments of CHAR Types.

Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be conditionally evaluated.
Returns:
A char representing the result of the evaluation.
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 conditionally evaluate arguments of BOOLEAN Types.

Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be conditionally evaluated.
Returns:
A boolean representing the result of the evaluation.
Throws: EvaluationException
If there is an evaluation failure.
Overrides:
evaluateBoolean in class Function
 o instance
 public final Primitive instance()
Creates an If Object of the same type.

Returns:
A reference to the same Object since no instance varaibles need to be changed.
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