Package org.moeaframework.util.progress
Class ProgressHelper
java.lang.Object
org.moeaframework.util.progress.ProgressHelper
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 Summary
ConstructorDescriptionProgressHelper
(Executor executor) Constructs a new progress helper for generating progress reports for the given executor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addProgressListener
(ProgressListener listener) Adds the given listener to receive progress reports.void
nextSeed()
Increments the current seed and sets NFE to 0.void
removeProgressListener
(ProgressListener listener) Removes the given listener so it no longer receives progress reports.void
setCurrentAlgorithm
(Algorithm algorithm) Sets the currently running algorithm, so thatProgressEvent
s can access the algorithm object.void
setCurrentNFE
(int currentNFE) Sets the current number of objective function evaluations.void
setCurrentSeed
(int currentSeed) Sets the current seed.void
start
(int totalSeeds, int maxNFE, long maxTime) Prepares this progress helper for use.void
stop()
Stops this progress helper.
-
Constructor Details
-
ProgressHelper
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
Adds the given listener to receive progress reports.- Parameters:
listener
- the listener to receive progress reports
-
removeProgressListener
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, asnextSeed()
sets the current NFE to 0.- Parameters:
currentSeed
- the current seed being processed, starting at1
-
setCurrentAlgorithm
Sets the currently running algorithm, so thatProgressEvent
s 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 evaluatedmaxNFE
- the maximum number of objective function evaluations per seedmaxTime
- 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.
-