org.omegahat.Numerics.Optimizers
Class OptimizerAlgorithmBasic

java.lang.Object
  |
  +--org.omegahat.Numerics.Optimizers.OptimizerAlgorithmBasic
All Implemented Interfaces:
OptimizerAlgorithm
Direct Known Subclasses:
OptimizerAlgorithmBFGS

public abstract class OptimizerAlgorithmBasic
extends java.lang.Object
implements OptimizerAlgorithm

A class with some basic methods for any optimizer.

Mostly, this provides utilities, such as for handling the state, which can be used by algorithms with specific numerical methods.


Field Summary
protected  java.lang.Class arrayClass
           
protected  NumericArray arrayTemplate
          An object of the class to be used for NumericMatrix objects in the optimizer algorithm.
protected  boolean gradient
          Does this algorithm expect gradients to be computed for model points?
protected  boolean hessian
          Does this algorithm expect hessians (the matrix of second partial derivatives) to be computed for model points?
protected  java.lang.Class matrixClass
           
protected  DynamicPackage matrixPackage
          The package from which classes implementing NumericMatrix and NumericArray will be extracted.
protected  NumericMatrix matrixTemplate
          An object of the class to be used for NumericMatrix objects in the optimizer algorithm.
protected  ModelObjective model
           
protected  java.lang.Class modelPointClass
           
protected  ModelPoint modelPointTemplate
           
protected  ModelPointNumericInt start
          The starting point for the optimization.
protected  int state
           
 
Constructor Summary
OptimizerAlgorithmBasic()
           
 
Method Summary
 java.lang.Class getArrayClass()
          Accessor for arrayClass field
 NumericArray getArrayTemplate()
          Accessor for arrayTemplate field
 java.lang.Class getMatrixClass()
          Accessor for matrixClass field
 DynamicPackage getMatrixPackage()
          Accessor for matrixPackage field
 NumericMatrix getMatrixTemplate()
          Accessor for matrixTemplate field
 ModelObjective getModel()
          Accessor for model field
 java.lang.Class getModelPointClass()
          Accessor for modelPointClass field
 ModelPoint getModelPointTemplate()
          Accessor for modelPointTemplate field
 ModelPointNumericInt getStart()
          Accessor for start field
 int getState()
          Accessor for state field
 boolean hasGradient()
          Accessor for gradient field
 boolean hasHessian()
          Accessor for hessian field
 ModelPoint initialize(double[] parameters, OptimizerIterator opt)
          Initialize the iteration with these numerical values for the parameter estimates.
 ModelPoint initialize(ModelPoint theta, OptimizerIterator i)
          Initialize from a ModelPoint starting value and an iterator.
 NumericArray newArray()
          Generate a new object from the NumericArray class defined by the matrixPackage for this object.
 NumericMatrix newMatrix()
          Generate a new object from the NumericMatrix class defined by the matrixPackage for this object.
 ModelPoint newModelPoint()
          Generate a new object from the ModelPoint class defined by the matrixPackage for this object.
 java.lang.Class setArrayClass(java.lang.Class value)
          Accessor for setting arrayClass field
 NumericArray setArrayTemplate(NumericArray value)
          Accessor for setting arrayTemplate field
 boolean setGradient(boolean value)
          Accessor for setting gradient field
 boolean setHessian(boolean value)
          Accessor for setting hessian field
 java.lang.Class setMatrixClass(java.lang.Class value)
          Accessor for setting matrixClass field
 DynamicPackage setMatrixPackage()
          Establish the actual classes corresponding to the current matrixPackage property.
 DynamicPackage setMatrixPackage(DynamicPackage value)
          Accessor for setting matrixPackage field from a LinearAlgebra.Package object.
 DynamicPackage setMatrixPackage(java.lang.String packageName)
          Set the package to that corresponding to the specified name.
 NumericMatrix setMatrixTemplate(NumericMatrix value)
          Accessor for setting matrixTemplate field
 ModelObjective setModel(ModelObjective value)
          Accessor for setting model field
 java.lang.Class setModelPointClass(java.lang.Class value)
          Accessor for setting modelPointClass field
 ModelPoint setModelPointTemplate(ModelPoint value)
          Accessor for setting modelPointTemplate field
 ModelPointNumericInt setStart(ModelPointNumericInt value)
          Accessor for setting start field.
 ModelPointNumericInt setStart(NumericArray value)
          Set the start from a numeric array of parameter values.
 int setState(int value)
          Accessor for setting state field
 ModelPoint wrapup(ModelPoint pars, OptimizerIterator opt)
          Wrap up the completed iteration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.omegahat.Numerics.Optimizers.OptimizerAlgorithm
refine
 

Field Detail

model

protected ModelObjective model

start

protected ModelPointNumericInt start
The starting point for the optimization.

This property is normally set during initialization. If the specified ModelPoint includes the definition of the objective function, setting the start property defines the model objective as well.


state

protected int state

matrixPackage

protected DynamicPackage matrixPackage
The package from which classes implementing NumericMatrix and NumericArray will be extracted.


gradient

protected boolean gradient
Does this algorithm expect gradients to be computed for model points?

hessian

protected boolean hessian
Does this algorithm expect hessians (the matrix of second partial derivatives) to be computed for model points?

matrixClass

protected java.lang.Class matrixClass

arrayClass

protected java.lang.Class arrayClass

modelPointClass

protected java.lang.Class modelPointClass

modelPointTemplate

protected ModelPoint modelPointTemplate

matrixTemplate

protected NumericMatrix matrixTemplate
An object of the class to be used for NumericMatrix objects in the optimizer algorithm. Usually set up by the first initialize call to the algoirthm. See matrixPackage for the ways the package or class can be specified.

arrayTemplate

protected NumericArray arrayTemplate
An object of the class to be used for NumericMatrix objects in the optimizer algorithm. Usually set up by the first initialize call to the algoirthm. See matrixPackage for the ways the package or class can be specified.
Constructor Detail

OptimizerAlgorithmBasic

public OptimizerAlgorithmBasic()
Method Detail

getModel

public ModelObjective getModel()
Accessor for model field

setModel

public ModelObjective setModel(ModelObjective value)
Accessor for setting model field

getStart

public ModelPointNumericInt getStart()
Accessor for start field

setStart

public ModelPointNumericInt setStart(ModelPointNumericInt value)
Accessor for setting start field.


setStart

public ModelPointNumericInt setStart(NumericArray value)
Set the start from a numeric array of parameter values.

Uses the matrix package specified for this optimizer algorithm to create the internal start object with parameters of the same class the algorithm will use, independent of the arguments to setStart.


getState

public int getState()
Accessor for state field

setState

public int setState(int value)
Accessor for setting state field

getMatrixPackage

public DynamicPackage getMatrixPackage()
Accessor for matrixPackage field

setMatrixPackage

public DynamicPackage setMatrixPackage(DynamicPackage value)
Accessor for setting matrixPackage field from a LinearAlgebra.Package object.

hasGradient

public boolean hasGradient()
Accessor for gradient field

setGradient

public boolean setGradient(boolean value)
Accessor for setting gradient field

hasHessian

public boolean hasHessian()
Accessor for hessian field

setHessian

public boolean setHessian(boolean value)
Accessor for setting hessian field

getMatrixClass

public java.lang.Class getMatrixClass()
Accessor for matrixClass field

setMatrixClass

public java.lang.Class setMatrixClass(java.lang.Class value)
Accessor for setting matrixClass field

getArrayClass

public java.lang.Class getArrayClass()
Accessor for arrayClass field

setArrayClass

public java.lang.Class setArrayClass(java.lang.Class value)
Accessor for setting arrayClass field

getModelPointClass

public java.lang.Class getModelPointClass()
Accessor for modelPointClass field

setModelPointClass

public java.lang.Class setModelPointClass(java.lang.Class value)
Accessor for setting modelPointClass field

getModelPointTemplate

public ModelPoint getModelPointTemplate()
Accessor for modelPointTemplate field

setModelPointTemplate

public ModelPoint setModelPointTemplate(ModelPoint value)
Accessor for setting modelPointTemplate field

getMatrixTemplate

public NumericMatrix getMatrixTemplate()
Accessor for matrixTemplate field

setMatrixTemplate

public NumericMatrix setMatrixTemplate(NumericMatrix value)
Accessor for setting matrixTemplate field

getArrayTemplate

public NumericArray getArrayTemplate()
Accessor for arrayTemplate field

setArrayTemplate

public NumericArray setArrayTemplate(NumericArray value)
Accessor for setting arrayTemplate field

initialize

public ModelPoint initialize(double[] parameters,
                             OptimizerIterator opt)
Initialize the iteration with these numerical values for the parameter estimates.

The model to be used for the start property must have been defined before this initialize method is called, since only the numeric values of the parameters are supplied here.


initialize

public ModelPoint initialize(ModelPoint theta,
                             OptimizerIterator i)
Initialize from a ModelPoint starting value and an iterator. The model point object defines both the form of the model and the numerical values to use as starting estimates.

The returned value is not necessarily identical to the argument, because the particular NumericArray class used to store the parameter values must match that needed for the computations of this algorithm. The initializer will in this case replace the parameter estimates in theta with an array of the correct class, but with the same numerical values.

Specified by:
initialize in interface OptimizerAlgorithm

wrapup

public ModelPoint wrapup(ModelPoint pars,
                         OptimizerIterator opt)
Wrap up the completed iteration.

The basic method does nothing. Over-riding methods may want to complete some estimates at the convergent parameter values (after testing the state of the optimization iterator against OptimizerIterator.CONVERGED).

Specified by:
wrapup in interface OptimizerAlgorithm

setMatrixPackage

public DynamicPackage setMatrixPackage(java.lang.String packageName)
Set the package to that corresponding to the specified name.

Individual classes then have names corresponding to the convention of appending the package name to the corresponding interface's name (see DynamicPackage documentation for details).


setMatrixPackage

public DynamicPackage setMatrixPackage()
Establish the actual classes corresponding to the current matrixPackage property. See matrixPackage for the options.

newMatrix

public NumericMatrix newMatrix()
Generate a new object from the NumericMatrix class defined by the matrixPackage for this object.

newArray

public NumericArray newArray()
Generate a new object from the NumericArray class defined by the matrixPackage for this object.

newModelPoint

public ModelPoint newModelPoint()
Generate a new object from the ModelPoint class defined by the matrixPackage for this object.
Specified by:
newModelPoint in interface OptimizerAlgorithm