org.omegahat.Numerics.Optimizers
Class DefaultListener

java.lang.Object
  |
  +--org.omegahat.Numerics.Optimizers.DefaultListener
All Implemented Interfaces:
CounterListener, java.util.EventListener, IterationListener

public class DefaultListener
extends java.lang.Object
implements CounterListener

A default, general purpose controller for optimization iteration.

A listener from this class implements the CounterListener interface and contains a ConvergenceGradient object to test successful completion.

The optimzer objects created from class Optimizer and its subclasses will add a listener of this class when they are instantiated (specifically, in their make method). If you do not want this test, call the optimizer's dropListener() method after creating the optimizer (and then you should add some alternative controlling listener if you expect evaluation not to go on forever).


Field Summary
protected  ConvergenceListenerInt convergence
           
protected  int count
          The counter for iterations of the optimizer.
protected  int max
          The maximum count (number of iterations).
 
Constructor Summary
DefaultListener()
          The standard default listener object is created with a ConvergenceGradient test and checks the maximum iteration count, against 10 times the number of parameters.
 
Method Summary
 boolean continueIteration(IterationEvent ev)
          Apply the tests for too many iterations or for numeric convergence.
 ConvergenceListenerInt getConvergence()
          Accessor for convergence field
 int getCount()
          Accessor for count field
 int getMax()
          Accessor for max field
 ConvergenceListenerInt setConvergence(ConvergenceListenerInt value)
          Accessor for setting convergence field
 int setCount(int value)
          Accessor for setting count field
 int setMax(int value)
          Accessor for setting max field
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

count

protected int count
The counter for iterations of the optimizer.

max

protected int max
The maximum count (number of iterations).

Set to -1 on creation. If not explicitly set, it will be automatically set to 10 times the number of parameters on the first call to continueIteration.


convergence

protected ConvergenceListenerInt convergence
Constructor Detail

DefaultListener

public DefaultListener()
The standard default listener object is created with a ConvergenceGradient test and checks the maximum iteration count, against 10 times the number of parameters.
Method Detail

getCount

public int getCount()
Accessor for count field
Specified by:
getCount in interface CounterListener

setCount

public int setCount(int value)
Accessor for setting count field
Specified by:
setCount in interface CounterListener

getMax

public int getMax()
Accessor for max field
Specified by:
getMax in interface CounterListener

setMax

public int setMax(int value)
Accessor for setting max field
Specified by:
setMax in interface CounterListener

getConvergence

public ConvergenceListenerInt getConvergence()
Accessor for convergence field

setConvergence

public ConvergenceListenerInt setConvergence(ConvergenceListenerInt value)
Accessor for setting convergence field

continueIteration

public boolean continueIteration(IterationEvent ev)
Apply the tests for too many iterations or for numeric convergence.

The max property contols the first test. To control convergence tests, either add additional listeners with your own custom tests, or modify the convergence property of this listener if you want to override the standard test.

Specified by:
continueIteration in interface IterationListener