|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--org.omegahat.Numerics.Optimizers.OptimizerBasic
|
+--org.omegahat.Numerics.Optimizers.OptimizerNotifying
Optimizer objects that notify listeners during iteration.
Objects can register to be notified after each step in the iteration of the optimizer (and also at initialization and termination of the iteration). The action method of the listener is called with the current model point and also the optimizer object itself as arguments. It can therefore display some information about the iteration but, via the second argument, can also interfere in the optimization.
| Field Summary | |
static int |
BACKGROUND
|
protected BackgroundTaskManager |
backgroundManager
This manager takes care of the background, or non-blocking, listeners. |
static int |
COMPLETION
|
protected ConvergenceListenerInt |
convergence
|
static int |
INFORMATION
|
static int |
INITIALIZATION
symbolic constants to index the array of listeners. |
protected IterationCounterInt |
iteration
|
static int |
ITERATION
|
protected java.util.Vector[] |
listeners
An array of objects, each of which is a list of listeners of a particular type. |
static int |
NUM_LISTENER_VECTORS
|
| Fields inherited from class org.omegahat.Numerics.Optimizers.OptimizerBasic |
algorithm, current, objective, state |
| Fields inherited from interface org.omegahat.Numerics.Optimizers.OptimizerIterator |
CONTINUE, CONVERGED, EXCEPTION, NUMERIC_PROBLEM, TOO_MANY_STEPS |
| Constructor Summary | |
OptimizerNotifying(OptimizerAlgorithm fitter)
|
|
OptimizerNotifying(OptimizerAlgorithm fitter,
ModelObjective model,
double[] start)
|
|
OptimizerNotifying(OptimizerAlgorithm fitter,
ModelPoint start)
|
|
| Method Summary | |
void |
addBackgroundListener(IterationListener l)
|
void |
addConvergedListener(IterationListener l)
A listener to be called only on completion. |
void |
addInitializationListener(IterationListener l)
A listener to be called only on initialization. |
void |
addIterationListener(IterationListener l)
Add a listener only to be called at each step in the iteration. |
void |
addListener(java.util.EventListener l)
Add a listener to the optimizer. |
boolean |
addListener(java.util.EventListener l,
int type)
A listener added with a computed type, which should be one of the pre-defined static constants in this class. |
void |
addStepListener(IterationListener l)
A listener to be called only after each iteration step. |
BackgroundTaskManager |
backgroundManager()
|
BackgroundTaskManager |
backgroundManager(BackgroundTaskManager m)
|
BackgroundTaskManager |
backgroundManager(BackgroundTaskManager m,
boolean start)
|
boolean |
continueIteration(OptimizerAlgorithm opt,
ModelPoint values)
Called after each iteration to test whether to continue. |
ModelPoint |
eval()
Carry out the iteration. |
void |
exchangeListener(java.util.EventListener old,
java.util.EventListener current,
int type)
Remove old from the listeners of this type, and add current. |
ConvergenceListenerInt |
getConvergence()
Accessor for convergence field |
IterationCounterInt |
getIteration()
Accessor for iteration field |
java.util.Vector[] |
getListeners()
|
ModelPoint |
initialize(ModelPoint initialValue)
Initialize the optimizer with the values supplied. |
ModelPoint |
initialize(ModelPoint initialValues,
IterationCounter l)
Initialize the iteration. |
void |
make()
Make the structures in the object. |
void |
notifyBackgroundListeners(IterationEvent event)
Notify all background listeners of the event. |
void |
notifyInformationListeners(IterationEvent ev)
Notify all the information listeners of the event. |
void |
notifyListeners(IterationEvent event)
Notify all listeners of the given event. |
void |
notifyListeners(ModelPoint values,
int type)
Notify all listeners of the given type of an IterationEvent containing the specified values for the model. |
ConvergenceListenerInt |
setConvergence(ConvergenceListenerInt value)
Accessor for setting convergence field |
IterationCounterInt |
setIteration(IterationCounterInt value)
Accessor for setting iteration field |
java.util.Vector[] |
setListeners(java.util.Vector[] v)
|
| Methods inherited from class org.omegahat.Numerics.Optimizers.OptimizerBasic |
eval, getAlgorithm, getCurrent, getObjective, getState, setAlgorithm, setCurrent, setObjective, setState |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int INITIALIZATION
public static final int COMPLETION
public static final int ITERATION
public static final int BACKGROUND
public static final int INFORMATION
public static final int NUM_LISTENER_VECTORS
protected java.util.Vector[] listeners
protected BackgroundTaskManager backgroundManager
protected IterationCounterInt iteration
protected ConvergenceListenerInt convergence
| Constructor Detail |
public OptimizerNotifying(OptimizerAlgorithm fitter)
public OptimizerNotifying(OptimizerAlgorithm fitter,
ModelPoint start)
public OptimizerNotifying(OptimizerAlgorithm fitter,
ModelObjective model,
double[] start)
| Method Detail |
public void make()
Called from each of the constructors.
public ModelPoint initialize(ModelPoint initialValues,
IterationCounter l)
throws java.lang.Exception
After initializing the fitting algorithm, adds the supplied iteration counter to the listeners. Calling the initializer with a null counter avoids the default control on the number of iterations.
public ModelPoint initialize(ModelPoint initialValue)
throws java.lang.Exception
An iteration counter will be installed with a default maximum, unless there is already a counter among the listeners.
initialize in class OptimizerBasic
public ModelPoint eval()
throws java.lang.Exception
eval in class OptimizerBasic
public void notifyListeners(ModelPoint values,
int type)
public void notifyListeners(IterationEvent event)
public void notifyInformationListeners(IterationEvent ev)
public void notifyBackgroundListeners(IterationEvent event)
The actual performance of the corresponding tasks is the responsibility of an object of class BackgroundTaskManager.
public boolean continueIteration(OptimizerAlgorithm opt,
ModelPoint values)
OptimizerBasicThe basic method only checks the state of the optimizer, which must have been set by some other computation. In the subclass OptimizerNotifier the corresponding method calls all the iteration listeners. By default these include a counter that exits when too many iterations have taken place. The algorithm will likely add listener(s) of its own, to detect successful convergence.
continueIteration in class OptimizerBasicpublic void addListener(java.util.EventListener l)
The listeners will be called once on startup and again after each iterative step of refinement. In other words, the listener gets to examine the optimization for each step, including the initial one.
The argument can be an instance of: InformationListener, IterationListener, or BackgroundListener.
public void addIterationListener(IterationListener l)
If the listener is an IterationCounter and there is currently no iteration counter in this optimizer, make this the iteration property. Similarly if the listener is the first ConvergenceListener, make this the convergence property. (Either property may be set directly, or set to null to reset the property.)
public void addBackgroundListener(IterationListener l)
public void addInitializationListener(IterationListener l)
public void addConvergedListener(IterationListener l)
public void addStepListener(IterationListener l)
public boolean addListener(java.util.EventListener l,
int type)
public void exchangeListener(java.util.EventListener old,
java.util.EventListener current,
int type)
public java.util.Vector[] getListeners()
public java.util.Vector[] setListeners(java.util.Vector[] v)
public BackgroundTaskManager backgroundManager()
public BackgroundTaskManager backgroundManager(BackgroundTaskManager m)
public BackgroundTaskManager backgroundManager(BackgroundTaskManager m,
boolean start)
public IterationCounterInt getIteration()
iteration fieldpublic IterationCounterInt setIteration(IterationCounterInt value)
iteration fieldpublic ConvergenceListenerInt getConvergence()
convergence fieldpublic ConvergenceListenerInt setConvergence(ConvergenceListenerInt value)
convergence field
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||