gov.sandia.cognition.learning.function
Class LinearCombinationFunction<InputType,OutputType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.LinearCombinationFunction<InputType,OutputType>
Type Parameters:
InputType - Input class of the Evaluator basis functions
OutputType - Output class of the Evaluator basis functions
All Implemented Interfaces:
Evaluator<InputType,OutputType>, Vectorizable, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
LinearCombinationScalarFunction, LinearCombinationVectorFunction

public abstract class LinearCombinationFunction<InputType,OutputType>
extends AbstractCloneableSerializable
implements Evaluator<InputType,OutputType>, Vectorizable

A function whose output is a weighted linear combination of (potentially) nonlinear basis function. The output is produced as: y = a0*f0(x) + a1*f1(x) + ... + an*fn(x), where "y" is the output, "x" is the given input, "ai" is the ith coefficient and "fi" is the ith basis function

Since:
2.0
Author:
Kevin R. Dixon
See Also:
WeightedBinaryEnsemble, Serialized Form

Constructor Summary
LinearCombinationFunction(ArrayList<? extends Evaluator<? super InputType,? extends OutputType>> basisFunctions, Vector coefficients)
          Creates a new instance of LinearCombinationFunction
 
Method Summary
 LinearCombinationFunction<InputType,OutputType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 void convertFromVector(Vector parameters)
          Converts the object from a Vector of parameters.
 Vector convertToVector()
          Converts the object to a vector.
abstract  OutputType evaluate(InputType input)
          Evaluates the LinearCombinationFunction about the given input.
 ArrayList<? extends Evaluator<? super InputType,? extends OutputType>> getBasisFunctions()
          Getter for basisFunctions
 Vector getCoefficients()
          Getter for coefficients
 void setBasisFunctions(ArrayList<? extends Evaluator<? super InputType,? extends OutputType>> basisFunctions)
          Setter for basisFunctions
 void setCoefficients(Vector coefficients)
          Setter for coefficients
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinearCombinationFunction

public LinearCombinationFunction(ArrayList<? extends Evaluator<? super InputType,? extends OutputType>> basisFunctions,
                                 Vector coefficients)
Creates a new instance of LinearCombinationFunction

Parameters:
basisFunctions - Collection of basis functions to combine to produce the output
coefficients - Coefficients for the basisFunctions
Method Detail

clone

public LinearCombinationFunction<InputType,OutputType> clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface Vectorizable
Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A clone of this object.

getCoefficients

public Vector getCoefficients()
Getter for coefficients

Returns:
Coefficients for the basisFunctions

setCoefficients

public void setCoefficients(Vector coefficients)
Setter for coefficients

Parameters:
coefficients - Coefficients for the basisFunctions

getBasisFunctions

public ArrayList<? extends Evaluator<? super InputType,? extends OutputType>> getBasisFunctions()
Getter for basisFunctions

Returns:
Collection of basis functions to combine to produce the output

setBasisFunctions

public void setBasisFunctions(ArrayList<? extends Evaluator<? super InputType,? extends OutputType>> basisFunctions)
Setter for basisFunctions

Parameters:
basisFunctions - Collection of basis functions to combine to produce the output

convertToVector

public Vector convertToVector()
Description copied from interface: Vectorizable
Converts the object to a vector.

Specified by:
convertToVector in interface Vectorizable
Returns:
The Vector form of the object.

convertFromVector

public void convertFromVector(Vector parameters)
Description copied from interface: Vectorizable
Converts the object from a Vector of parameters.

Specified by:
convertFromVector in interface Vectorizable
Parameters:
parameters - The parameters to incorporate.

toString

public String toString()
Overrides:
toString in class Object

evaluate

public abstract OutputType evaluate(InputType input)
Evaluates the LinearCombinationFunction about the given input. The output is produced as: y = a0*f0(x) + a1*f1(x) + ... + an*fn(x), where "y" is the output, "x" is the given input, "ai" is the ith coefficient and "fi" is the ith basis function

Specified by:
evaluate in interface Evaluator<InputType,OutputType>
Parameters:
input - The input about which to compute the output
Returns:
y = a0*f0(x) + a1*f1(x) + ... + an*fn(x)