org.omegahat.Numerics.Optimizers
Class NotifyingOptimizer

java.lang.Object
  |
  +--org.omegahat.Numerics.Optimizers.BasicOptimizer
        |
        +--org.omegahat.Numerics.Optimizers.NotifyingOptimizer
All Implemented Interfaces:
OptimizerIterator

public class NotifyingOptimizer
extends BasicOptimizer


Field Summary
protected  BackgroundTaskManager backgroundManager
           
static int BLOCKING_ITERATION
           
static int COMPLETION
           
static int INITIALIZATION
           
protected  java.util.Vector[] listeners
           
static int NON_BLOCKING_ITERATION
           
static int NUM_LISTENER_VECTORS
           
 
Fields inherited from class org.omegahat.Numerics.Optimizers.BasicOptimizer
convergenceChecker, fitter, maxNumIterations, numIterations
 
Fields inherited from interface org.omegahat.Numerics.Optimizers.OptimizerIterator
CONTINUE, CONVERGED, EXCEPTION, NUMERIC_PROBLEM, TOO_MANY_STEPS
 
Constructor Summary
NotifyingOptimizer(OptimizerAlgorithm fitter)
           
NotifyingOptimizer(OptimizerAlgorithm fitter, ConvergenceChecker convergence)
           
 
Method Summary
 void addBackgroundIterationListener(IterationListener l)
           
 void addConvergedListener(IterationListener l)
           
 void addInitializationListener(IterationListener l)
           
 void addIterationListener(IterationListener l)
           
 boolean addListener(IterationListener l, int type)
           
 BackgroundTaskManager backgroundManager()
           
 BackgroundTaskManager backgroundManager(BackgroundTaskManager m)
           
 BackgroundTaskManager backgroundManager(BackgroundTaskManager m, boolean start)
           
 ParameterSet eval(ParameterSet initialValues)
          The basic optimization loop.
 java.util.Vector[] listeners()
           
 java.util.Vector[] listeners(java.util.Vector[] v)
           
 void notifyBackgroundListeners(IterationEvent event)
           
 void notifyListeners(ParameterSet values, int type)
           
 
Methods inherited from class org.omegahat.Numerics.Optimizers.BasicOptimizer
addToHistory, completedIteration, convergenceChecker, convergenceChecker, eval, fitter, fitter, handleError, hasConverged, maxNumIterations, maxNumIterations, numIterations, numIterations
 
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.OptimizerIterator
continueIteration, getState, setState
 

Field Detail

INITIALIZATION

public static final int INITIALIZATION

COMPLETION

public static final int COMPLETION

BLOCKING_ITERATION

public static final int BLOCKING_ITERATION

NUM_LISTENER_VECTORS

public static final int NUM_LISTENER_VECTORS

NON_BLOCKING_ITERATION

public static final int NON_BLOCKING_ITERATION

listeners

protected java.util.Vector[] listeners

backgroundManager

protected BackgroundTaskManager backgroundManager
Constructor Detail

NotifyingOptimizer

public NotifyingOptimizer(OptimizerAlgorithm fitter)

NotifyingOptimizer

public NotifyingOptimizer(OptimizerAlgorithm fitter,
                          ConvergenceChecker convergence)
Method Detail

eval

public ParameterSet eval(ParameterSet initialValues)
Description copied from class: BasicOptimizer
The basic optimization loop. Calls the algorithm in a loop to compute the next set of parameter values, by invoking the refine method of the fitter.

The object's hasConverged method is called both before and after calling the refine method (if this method does a fair amount of work you might want it to check immediately that it got different parameter values from the previous call).

If the internal convergence test does not break out of the loop, a hook is called, which does nothing much in this class, but notifies listeners in the subclass NotifyingOptimizer. Rather than build in hard-coded tests, the structure of this class and its subclasses allows very general techniques for testing convergence to be added at three different levels:

  1. In the algorithm's hasConverged method, for tests that are intrinsic to the numerical technique;
  2. By setting a ConvergenceChecker method in this optimizer object itself that makes a convergence test directly;
  3. Through an IterationListener object that is notified, makes a test, and throws an InterruptedIterationException, which the eval method will catch (and simply treat as a break out of the iteration).
It is also possible to throw other exceptions from listeners (or from errors in the computations, of course). However, the BasicOptimizer class catches these and ignores them, except for printing an error message and a stack trace.
Overrides:
eval in class BasicOptimizer

notifyListeners

public void notifyListeners(ParameterSet values,
                            int type)

notifyBackgroundListeners

public void notifyBackgroundListeners(IterationEvent event)

addIterationListener

public void addIterationListener(IterationListener l)

addBackgroundIterationListener

public void addBackgroundIterationListener(IterationListener l)

addInitializationListener

public void addInitializationListener(IterationListener l)

addConvergedListener

public void addConvergedListener(IterationListener l)

addListener

public boolean addListener(IterationListener l,
                           int type)

listeners

public java.util.Vector[] listeners()

listeners

public java.util.Vector[] listeners(java.util.Vector[] v)

backgroundManager

public BackgroundTaskManager backgroundManager()

backgroundManager

public BackgroundTaskManager backgroundManager(BackgroundTaskManager m)

backgroundManager

public BackgroundTaskManager backgroundManager(BackgroundTaskManager m,
                                               boolean start)