ec.cgp.functions
Interface Functions

All Known Implementing Classes:
FunctionsBreastCancerW, FunctionsBreastCancerY, FunctionsIris, FunctionsParity, FunctionsRegression

public interface Functions

This interface defines how the Cartesian Genetic Program evaluator calls user-defined functions when they are encountered in the genome. You must provide an implementation of this interface when plugging functions into the CGP evaluations.

Author:
David Oranchak, doranchak@gmail.com, http://oranchak.com

Method Summary
 int arityOf(int fn)
          Return the arity of the given function.
 java.lang.Object callFunction(java.lang.Object[] inputs, int function, int numFunctions)
          Executes the given function with the given inputs.
 java.lang.String functionName(int fn)
          Return a string representation of the given function name, used when putting together the string representing the entire Cartesian Genetic Program.
 java.lang.String inputName(int inp, java.lang.Object val)
          Obtain a string representation of the given input.
 

Method Detail

callFunction

java.lang.Object callFunction(java.lang.Object[] inputs,
                              int function,
                              int numFunctions)
Executes the given function with the given inputs.

Parameters:
inputs - The arguments passed to the function. It is possible that some or all of the arguments will be unused by some functions.
function - The function number. Every function number must map to a function.
numFunctions - The total number of functions available.
Returns:
the result of the function call

functionName

java.lang.String functionName(int fn)
Return a string representation of the given function name, used when putting together the string representing the entire Cartesian Genetic Program.

Parameters:
fn - The function number
Returns:
The descriptive function name that corresponds to this function number.

inputName

java.lang.String inputName(int inp,
                           java.lang.Object val)
Obtain a string representation of the given input.

Parameters:
inp - The input number
val - Optional input value (needed if you want to display a constant value for this input)
Returns:
The descriptive input name that corresponds to this input.

arityOf

int arityOf(int fn)
Return the arity of the given function.

Parameters:
fn - the function number
Returns:
The number of inputs this function expects.