org.omegahat.Numerics.Optimizers
Class ConvergenceListener

java.lang.Object
  |
  +--org.omegahat.Numerics.Optimizers.ConvergenceListener
All Implemented Interfaces:
ConvergenceListenerInt, java.util.EventListener, IterationListener
Direct Known Subclasses:
ConvergenceGradient

public abstract class ConvergenceListener
extends java.lang.Object
implements ConvergenceListenerInt

Basic class to provide tests of numeric convergence for optimization.

The object has a tolerance and a current value (which should depend on the current contents of the optimizer).

This class is abstract because it does not implement setValue, the method that computes the criterion from the model. Most implementing classes will only need to supply this method.


Field Summary
static double relPrecision
          The relative precision of type double; that is, the smallest positive number which added to 1.0 gives a number larger than 1.0.
protected  double tolerance
          The tolerance for convergence tests.
protected  double value
           
 
Constructor Summary
ConvergenceListener()
           
 
Method Summary
 boolean continueIteration(IterationEvent ev)
          The method called at each iteration.
 double getTolerance()
          Accessor for tolerance field
 double getValue()
          Accessor for value field
 double setTolerance(double value)
          Accessor for setting tolerance field
 double setValue(double value)
          Accessor for setting value field
abstract  double setValue(ModelPoint parameters, OptimizerIterator opt)
          Set the value from the current model point and optimizer object (the usual way to do it).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

relPrecision

public static final double relPrecision
The relative precision of type double; that is, the smallest positive number which added to 1.0 gives a number larger than 1.0. (in the Java numeric model, about 2.2e-16).

value

protected double value

tolerance

protected double tolerance
The tolerance for convergence tests.

The field is initialized to the relative precision (field relPrecision in this class).

Constructor Detail

ConvergenceListener

public ConvergenceListener()
Method Detail

getValue

public double getValue()
Accessor for value field
Specified by:
getValue in interface ConvergenceListenerInt

setValue

public double setValue(double value)
Accessor for setting value field
Specified by:
setValue in interface ConvergenceListenerInt

getTolerance

public double getTolerance()
Accessor for tolerance field
Specified by:
getTolerance in interface ConvergenceListenerInt

setTolerance

public double setTolerance(double value)
Accessor for setting tolerance field
Specified by:
setTolerance in interface ConvergenceListenerInt

continueIteration

public boolean continueIteration(IterationEvent ev)
The method called at each iteration.

It calls the setValue method with the model point and the optimizer as arguments, and returns false (meaning don't continue the iteration) if the value is less than the tolerance.

The optimizer's state is set to OptimizerIterator.CONVERGED in this case. Subclasses may want to specialize this setting to distinguish the particular test.

Specified by:
continueIteration in interface IterationListener

setValue

public abstract double setValue(ModelPoint parameters,
                                OptimizerIterator opt)
Description copied from interface: ConvergenceListenerInt
Set the value from the current model point and optimizer object (the usual way to do it).
Specified by:
setValue in interface ConvergenceListenerInt