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
| 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 |
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
NotifyingOptimizer
public NotifyingOptimizer(OptimizerAlgorithm fitter)
NotifyingOptimizer
public NotifyingOptimizer(OptimizerAlgorithm fitter,
ConvergenceChecker convergence)
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:
- In the algorithm's hasConverged
method, for tests that are intrinsic to the numerical technique;
- By setting a ConvergenceChecker
method in this optimizer object itself that makes a convergence
test directly;
- 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)