geneticWedge.gp.function
Class Function

java.lang.Object
  extended by geneticWedge.gp.Component
      extended by geneticWedge.gp.function.Function
Direct Known Subclasses:
OneInputFunction, TwoInputFunction

public abstract class Function
extends Component

The abstract parent of all Functions. Functions are Components that are used within a tree, i.e. not at its leaves. They must be able to calculate an output given an array of inputs. Generally the input array must be of a specific length otherwise an InvalidInputSizeException will be thrown upon calling getOutput().


Constructor Summary
Function()
           
 
Method Summary
 int getComplexity()
          Should return the complexity of the Function.
 int getNoOfInputs()
          Should return the length of the array required by getOutput()
abstract  double getOutput(double[] inputs)
          All non-abstract subclasses must implement this method, so that they can transform inputs into a single output.
abstract  java.lang.String toString()
          Returns a String representation of this Function object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Function

public Function()
Method Detail

getOutput

public abstract double getOutput(double[] inputs)
                          throws InvalidInputSizeException
All non-abstract subclasses must implement this method, so that they can transform inputs into a single output.

Throws:
InvalidInputSizeException

toString

public abstract java.lang.String toString()
Returns a String representation of this Function object. The String representations should be different for different classes.

Specified by:
toString in class Component

getNoOfInputs

public int getNoOfInputs()
Should return the length of the array required by getOutput()


getComplexity

public int getComplexity()
Should return the complexity of the Function. Simple arithmetic functions have complexity 0, while higher order functions like pow have higher complexities.