edu.uci.ics.jung.algorithms
Class IterativeProcess

java.lang.Object
  extended by edu.uci.ics.jung.algorithms.IterativeProcess
Direct Known Subclasses:
AbstractRanker, EdmondsKarpMaxFlow, SimulatedAnnealer

public abstract class IterativeProcess
extends Object

Provides basic infrastructure for iterative algorithms. Services provided include:

Algorithms that subclass this class are typically used in the following way:

 FooAlgorithm foo = new FooAlgorithm(...)
 foo.setMaximumIterations(100); //set up conditions
 ...
 foo.evaluate(); //key method which initiates iterative process
 foo.getSomeResult();
 

Author:
Scott White (originally written by Didier Besset)

Constructor Summary
IterativeProcess()
          Generic constructor.
 
Method Summary
 void evaluate()
          Performs the iterative process.
protected abstract  double evaluateIteration()
          Evaluate the result of the current interation.
protected  void finalizeIterations()
          Perform eventual clean-up operations (must be implement by subclass when needed).
 double getDesiredPrecision()
          Returns the desired precision.
 int getIterations()
          Returns the number of iterations performed.
 int getMaximumIterations()
          Returns the maximum allowed number of iterations.
 double getPrecision()
          Returns the attained precision.
 boolean hasConverged()
          Check to see if the result has been attained.
protected  void initializeIterations()
          Initializes internal parameters to start the iterative process.
protected  void reinitialize()
           
 double relativePrecision(double epsilon, double x)
           
 void setDesiredPrecision(double prec)
          Defines the desired precision.
 void setMaximumIterations(int maxIter)
          Defines the maximum allowed number of iterations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IterativeProcess

public IterativeProcess()
Generic constructor.

Method Detail

evaluate

public void evaluate()
Performs the iterative process. Note: this method does not return anything because Java does not allow mixing double, int, or objects


evaluateIteration

protected abstract double evaluateIteration()
Evaluate the result of the current interation.

Returns:
the estimated precision of the result.

finalizeIterations

protected void finalizeIterations()
Perform eventual clean-up operations (must be implement by subclass when needed).


getDesiredPrecision

public double getDesiredPrecision()
Returns the desired precision.


getIterations

public int getIterations()
Returns the number of iterations performed.


getMaximumIterations

public int getMaximumIterations()
Returns the maximum allowed number of iterations.


getPrecision

public double getPrecision()
Returns the attained precision.


hasConverged

public boolean hasConverged()
Check to see if the result has been attained.

Returns:
boolean

initializeIterations

protected void initializeIterations()
Initializes internal parameters to start the iterative process.


reinitialize

protected void reinitialize()

relativePrecision

public double relativePrecision(double epsilon,
                                double x)
Parameters:
epsilon - double
x - double
Returns:
double

setDesiredPrecision

public void setDesiredPrecision(double prec)
                         throws IllegalArgumentException
Defines the desired precision.

Throws:
IllegalArgumentException

setMaximumIterations

public void setMaximumIterations(int maxIter)
                          throws IllegalArgumentException
Defines the maximum allowed number of iterations.

Throws:
IllegalArgumentException