lnsc
Class AbstractSimpleUnit

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

public abstract class AbstractSimpleUnit
extends AbstractFunctionalUnit

Abstract class containing the basic implementation for simple univariate single-real-valued FunctionalUnit. These functions will have the form f'(x) = factor*f(x) + offset where f(x) needs to be implemented.

This class encapsulates all the methods and slots required to create a functional unit of 1 input and 1 output from the class AbstractFunctionUnit. It is the fastest way to create such units. Only 3 simple things are needed by subclasses:

  1. In the constructor, the field m_IsDifferentiable must be filled appropriately. (m_IsStateless is assumed true)
  2. Only the simple methods function(double), and functionDerivative(double) if the function is differentiable, need to be implemented.
  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 object, the Cloneable interface can rely on Tools.copyObject(Serializable).

Moreover, every function derived from AbstractSimpleUnit can also be re-scaled and offset to match any specific output range. The output computed by the original function(double) can be multiplied by factor and then translated by adding offset. The functionDerivative(double) is adjusted accordingly. By default factor = 1.0 and offset = 0.0.

Since:
1.0
See Also:
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
AbstractSimpleUnit()
          Creates a simple unit with Factor=1.0 and Offset=0.0.
AbstractSimpleUnit(double newFactor, double newOffset)
          Creates a simple unit with given factor and offset.
 
Method Summary
 double getFactor()
          Returns the scaling factor applied to the internal output.
 double getOffset()
          Returns the value added to the scaled output.
 FunctionalUnit.ProcessPatternResult processPattern(double[] inputPattern, boolean computeDerivative, boolean computeSecondDerivative)
          Processes an input pattern and returns its output pattern and derivative (if requested).
 void setFactor(double newFactor)
          Sets the factor applied to the internal output.
 void setOffset(double newOffset)
          Sets the value added to the scaled output.
 java.lang.String toString()
           
 
Methods inherited from class lnsc.AbstractFunctionalUnit
clone, getInputCount, getOutputCount, isDifferentiable, isStateless, isTwiceDifferentiable, processDataSet, reset
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractSimpleUnit

public AbstractSimpleUnit()
Creates a simple unit with Factor=1.0 and Offset=0.0.


AbstractSimpleUnit

public AbstractSimpleUnit(double newFactor,
                          double newOffset)
Creates a simple unit with given factor and offset.

Parameters:
newFactor - Function factor.
newOffset - Function offset.
Method Detail

getFactor

public final double getFactor()
Returns the scaling factor applied to the internal output.

Returns:
Factor applied to the internal output.

getOffset

public final double getOffset()
Returns the value added to the scaled output.

Returns:
Value added to the scaled output.

processPattern

public final 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
Overrides:
processPattern in class AbstractFunctionalUnit
Returns:
The output pattern and the derivative (if requested).

setFactor

public final void setFactor(double newFactor)
Sets the factor applied to the internal output.

Parameters:
newFactor - Factor applied to the internal output.

setOffset

public final void setOffset(double newOffset)
Sets the value added to the scaled output.

Parameters:
newOffset - Value added to the scaled output.

toString

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