lnsc
Class AbstractFunctionalUnit

java.lang.Object
  |
  +--lnsc.AbstractFunctionalUnit
All Implemented Interfaces:
java.lang.Cloneable, FunctionalUnit, java.io.Serializable
Direct Known Subclasses:
AbstractSimpleUnit

public abstract class AbstractFunctionalUnit
extends java.lang.Object
implements FunctionalUnit

Abstract class containing the basic implementation for the FunctionalUnit interface.

In order to implement the FunctionalUnit interface, subclasses need the following 3 things:

  1. In the constructor, the fields m_InputCount, m_OutputCount, m_IsDifferentiable, and m_IsStateless must be filled appropriately.
  2. Either processDataSet(DataSet, String[]) or processPattern(double[], boolean) must be implemented and should prefrerably begin by calling preProcessDataSet(DataSet, String[]) or preProcessPattern(double[], boolean) respectively. For non stateless function, reset() must be added.
  3. Since FunctionalUnit are Serializable and Cloneable, any required extra code to make these interfaces work properly should be added. It is necessary to at least set the private static serialVersionUID variable appropriately for the Seriablizable interface. For complex objects, the Cloneable interface can rely on Tools.copyObject(Serializable).

Since:
1.0
See Also:
Tools.copyObject(Serializable), Serialized Form

Nested Class Summary
 
Nested classes inherited from class lnsc.FunctionalUnit
FunctionalUnit.ProcessPatternResult
 
Field Summary
 
Fields inherited from interface lnsc.FunctionalUnit
EMPTY_PATTERN
 
Constructor Summary
AbstractFunctionalUnit()
           
 
Method Summary
 java.lang.Object clone()
           
 int getInputCount()
          Indicates the number of variables of the function.
 int getOutputCount()
          Indicates the number of values returned by the function.
 boolean isDifferentiable()
          Indicates whether or not the function is differentiable.
 boolean isStateless()
          Indicates whether or not the function output depends solely of the current input (and not of the previous pattern it has processed).
 boolean isTwiceDifferentiable()
          Indicates whether or not the function is twice differentiable.
 DataSet processDataSet(DataSet dataSet, java.lang.String[] recordList)
          Processes a set of input patterns and record the requested information.
 FunctionalUnit.ProcessPatternResult processPattern(double[] inputPattern, boolean computeDerivative, boolean computeSecondDerivative)
          Processes an input pattern and returns its output pattern and derivative (if requested).
 void reset()
          Reset internal transient state for non stateless functions.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractFunctionalUnit

public AbstractFunctionalUnit()
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Specified by:
clone in interface FunctionalUnit
Overrides:
clone in class java.lang.Object
java.lang.CloneNotSupportedException

getInputCount

public final int getInputCount()
Description copied from interface: FunctionalUnit
Indicates the number of variables of the function.

Specified by:
getInputCount in interface FunctionalUnit
Returns:
Number of inputs.

getOutputCount

public final int getOutputCount()
Description copied from interface: FunctionalUnit
Indicates the number of values returned by the function.

Specified by:
getOutputCount in interface FunctionalUnit
Returns:
Number of outputs.

isDifferentiable

public final boolean isDifferentiable()
Description copied from interface: FunctionalUnit
Indicates whether or not the function is differentiable.

Specified by:
isDifferentiable in interface FunctionalUnit
Returns:
true if it differentiable, false otherwise.

isStateless

public final boolean isStateless()
Description copied from interface: FunctionalUnit
Indicates whether or not the function output depends solely of the current input (and not of the previous pattern it has processed). (Any such internal state use for next computation should be in transient variables and not being serialized. They should be reseted on reset.)

Specified by:
isStateless in interface FunctionalUnit
Returns:
true if output depends solely on current input false otherwise.

isTwiceDifferentiable

public final boolean isTwiceDifferentiable()
Description copied from interface: FunctionalUnit
Indicates whether or not the function is twice differentiable.

Specified by:
isTwiceDifferentiable in interface FunctionalUnit
Returns:
true if it twice differentiable, false otherwise.

processDataSet

public DataSet processDataSet(DataSet dataSet,
                              java.lang.String[] recordList)
Description copied from interface: FunctionalUnit
Processes a set of input patterns and record the requested information. To get the derivatives for each pattern, use the keyword DataNames.DERIVATIVES, for the second derivatives use DataNames.SECOND_DERIVATIVES and for the error patterns, use DataNames.ERROR_PATTERNS. Derivatives are available only when the function is differentiable. Error patterns required DataNames.TARGET_PATTERNS to be in the provided data set.

Specified by:
processDataSet in interface FunctionalUnit
Returns:
The given data set augmented with the DataNames.OUTPUT_PATTERNS and any other keywords supported requested. Each FunctionalUnit may provide extra keywords of its own.
See Also:
DataNames

processPattern

public FunctionalUnit.ProcessPatternResult processPattern(double[] inputPattern,
                                                          boolean computeDerivative,
                                                          boolean computeSecondDerivative)
Description copied from interface: FunctionalUnit
Processes an input pattern and returns its output pattern and derivative (if requested).

Specified by:
processPattern in interface FunctionalUnit
Returns:
The output pattern and the derivative (if requested).

reset

public void reset()
Description copied from interface: FunctionalUnit
Reset internal transient state for non stateless functions.

Specified by:
reset in interface FunctionalUnit

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object