org.apache.commons.math3.util

## Class IterationManager

- java.lang.Object
- - org.apache.commons.math3.util.IterationManager

-     public class IterationManager
      extends Object

  This abstract class provides a general framework for managing iterative algorithms. The maximum number of iterations can be set, and methods are provided to monitor the current iteration count. A lightweight event framework is also provided.
  Version:
    $Id: IterationManager.java 1244107 2012-02-14 16:17:55Z erans $

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `IterationManager(int maxIterations)` Creates a new instance of this class.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addIterationListener(IterationListener listener)` Attaches a listener to this manager.
    `void` | `fireInitializationEvent(IterationEvent e)` Informs all registered listeners that the initial phase (prior to the main iteration loop) has been completed.
    `void` | `fireIterationPerformedEvent(IterationEvent e)` Informs all registered listeners that a new iteration (in the main iteration loop) has been performed.
    `void` | `fireIterationStartedEvent(IterationEvent e)` Informs all registered listeners that a new iteration (in the main iteration loop) has been started.
    `void` | `fireTerminationEvent(IterationEvent e)` Informs all registered listeners that the final phase (post-iterations) has been completed.
    `int` | `getIterations()` Returns the number of iterations of this solver, 0 if no iterations has been performed yet.
    `int` | `getMaxIterations()` Returns the maximum number of iterations.
    `void` | `incrementIterationCount()` Increments the iteration count by one, and throws an exception if the maximum number of iterations is reached.
    `void` | `removeIterationListener(IterationListener listener)` Removes the specified iteration listener from the list of listeners currently attached to `this` object.
    `void` | `resetIterationCount()` Sets the iteration count to 0.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### IterationManager

          public IterationManager(int maxIterations)

      Creates a new instance of this class.
      Parameters:
        `maxIterations` - Maximum number of iterations.

  - ### Method Detail

    - #### addIterationListener

          public void addIterationListener(IterationListener listener)

      Attaches a listener to this manager.
      Parameters:
        `listener` - A `IterationListener` object.

    - #### fireInitializationEvent

          public void fireInitializationEvent(IterationEvent e)

      Informs all registered listeners that the initial phase (prior to the main iteration loop) has been completed.
      Parameters:
        `e` - The `IterationEvent` object.

    - #### fireIterationPerformedEvent

          public void fireIterationPerformedEvent(IterationEvent e)

      Informs all registered listeners that a new iteration (in the main iteration loop) has been performed.
      Parameters:
        `e` - The `IterationEvent` object.

    - #### fireIterationStartedEvent

          public void fireIterationStartedEvent(IterationEvent e)

      Informs all registered listeners that a new iteration (in the main iteration loop) has been started.
      Parameters:
        `e` - The `IterationEvent` object.

    - #### fireTerminationEvent

          public void fireTerminationEvent(IterationEvent e)

      Informs all registered listeners that the final phase (post-iterations) has been completed.
      Parameters:
        `e` - The `IterationEvent` object.

    - #### getIterations

          public int getIterations()

      Returns the number of iterations of this solver, 0 if no iterations has been performed yet.
      Returns:
        the number of iterations.

    - #### getMaxIterations

          public int getMaxIterations()

      Returns the maximum number of iterations.
      Returns:
        the maximum number of iterations.

    - #### incrementIterationCount

          public void incrementIterationCount()
                                       throws MaxCountExceededException

      Increments the iteration count by one, and throws an exception if the maximum number of iterations is reached. This method should be called at the beginning of a new iteration.
      Throws:
        `MaxCountExceededException` - if the maximum number of iterations is reached.

    - #### removeIterationListener

          public void removeIterationListener(IterationListener listener)

      Removes the specified iteration listener from the list of listeners currently attached to `this` object. Attempting to remove a listener which was not previously registered does not cause any error.
      Parameters:
        `listener` - The `IterationListener` to be removed.

    - #### resetIterationCount

          public void resetIterationCount()

      Sets the iteration count to 0. This method must be called during the initial phase.

Copyright © 2003-2012 The Apache Software Foundation. All Rights Reserved.