Class ProgressHelper

java.lang.Object
org.moeaframework.util.progress.ProgressHelper

public class ProgressHelper extends Object
Helper for notifying any ProgressListener when the evaluation progress of an Executor changes. This class reports the current progress, percent complete, elapsed time, and remaining time. Be sure to first call start(int, int, long) to set the total number of seeds and NFE prior to invoking any other method.
  • Constructor Details

    • ProgressHelper

      public ProgressHelper(Executor executor)
      Constructs a new progress helper for generating progress reports for the given executor.
      Parameters:
      executor - the executor that will be reporting progress
  • Method Details

    • addProgressListener

      public void addProgressListener(ProgressListener listener)
      Adds the given listener to receive progress reports.
      Parameters:
      listener - the listener to receive progress reports
    • removeProgressListener

      public void removeProgressListener(ProgressListener listener)
      Removes the given listener so it no longer receives progress reports.
      Parameters:
      listener - the listener to no longer receive progress reports
    • setCurrentNFE

      public void setCurrentNFE(int currentNFE)
      Sets the current number of objective function evaluations. This method will generate a progress report.
      Parameters:
      currentNFE - the current number of objective function evaluations
    • setCurrentSeed

      public void setCurrentSeed(int currentSeed)
      Sets the current seed. This call will have no affect if the current seed is unchanged. This method will generate a progress report if the current seed changes.

      It is strongly recommended that nextSeed() is used instead of this method, as nextSeed() sets the current NFE to 0.

      Parameters:
      currentSeed - the current seed being processed, starting at 1
    • setCurrentAlgorithm

      public void setCurrentAlgorithm(Algorithm algorithm)
      Sets the currently running algorithm, so that ProgressEvents can access the algorithm object.
      Parameters:
      algorithm - - the algorithm that is going to be running
    • nextSeed

      public void nextSeed()
      Increments the current seed and sets NFE to 0. This method will generate a progress report. This method should be invoked after every seed completes in order to notify listeners that the seed completed.
    • start

      public void start(int totalSeeds, int maxNFE, long maxTime)
      Prepares this progress helper for use. This method must be invoked prior to calling all other methods. The internal state of the progress helper is reset, allowing a single progress helper to be reused across many sequential runs.
      Parameters:
      totalSeeds - the total number of seeds to be evaluated
      maxNFE - the maximum number of objective function evaluations per seed
      maxTime - the maximum time
    • stop

      public void stop()
      Stops this progress helper. No other methods should be invoked after calling this method. However, start(int, int, long) can be called to reset and restart this progress helper.