Class IterationManager

java.lang.Object
org.hipparchus.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.
  • Constructor Details Link icon

    • IterationManager Link icon

      public IterationManager(int maxIterations)
      Creates a new instance of this class.
      Parameters:
      maxIterations - the maximum number of iterations
    • IterationManager Link icon

      public IterationManager(int maxIterations, Incrementor.MaxCountExceededCallback callBack)
      Creates a new instance of this class.
      Parameters:
      maxIterations - the maximum number of iterations
      callBack - the function to be called when the maximum number of iterations has been reached
      Throws:
      NullArgumentException - if callBack is null
  • Method Details Link icon

    • addIterationListener Link icon

      public void addIterationListener(IterationListener listener)
      Attaches a listener to this manager.
      Parameters:
      listener - A IterationListener object.
    • fireInitializationEvent Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      public void fireTerminationEvent(IterationEvent e)
      Informs all registered listeners that the final phase (post-iterations) has been completed.
      Parameters:
      e - The IterationEvent object.
    • getIterations Link icon

      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 Link icon

      public int getMaxIterations()
      Returns the maximum number of iterations.
      Returns:
      the maximum number of iterations.
    • incrementIterationCount Link icon

      public void incrementIterationCount() throws MathIllegalStateException
      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:
      MathIllegalStateException - if the maximum number of iterations is reached.
    • removeIterationListener Link icon

      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 Link icon

      public void resetIterationCount()
      Sets the iteration count to 0. This method must be called during the initial phase.