Package org.opt4j.core.optimizer
Class Control
- java.lang.Object
-
- org.opt4j.core.optimizer.Control
-
public class Control extends Object
The
Controlallows to pause, stop, and terminate, the optimization process.The
in which the process might get paused, terminated (by theOptimizercalls the methodsTerminationException) or stopped (by theStopException). By definition, aStopExceptionmight get thrown only between iterations, aTerminationExceptionalso within an iteration of the optimization algorithm. In this context, the optimization algorithm callscheckpointStop()between the iterations andcheckpoint()within the iteration.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classControl.StateTheControl.Stateof the control.
-
Field Summary
Fields Modifier and Type Field Description protected Set<ControlListener>listenersprotected Control.Statestate
-
Constructor Summary
Constructors Constructor Description Control()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(ControlListener listener)Adds aControlListener.voidcheckpoint()A checkpoint that checks for termination.voidcheckpointStop()A checkpoint that checks for termination and stop.voiddoPause()Pauses the optimization.voiddoStart()Starts the optimization.voiddoStop()Stops the optimization.voiddoTerminate()Terminates the optimization.Control.StategetState()Returns the state.booleanisPaused()Returnstrueif the optimization is paused.booleanisRunning()Returnstrueif the optimization is running.booleanisStopped()Returnstrueif the optimization is stopped.booleanisTerminated()Returnstrueif the optimization is terminated.voidremoveListener(ControlListener listener)Removes aControlListener.protected voidsetState(Control.State state)Sets the state and invokes listeners if the state has changed.
-
-
-
Field Detail
-
state
protected Control.State state
-
listeners
protected final Set<ControlListener> listeners
-
-
Method Detail
-
doStart
public void doStart()
Starts the optimization.
-
doPause
public void doPause()
Pauses the optimization.
-
doStop
public void doStop()
Stops the optimization.
-
doTerminate
public void doTerminate()
Terminates the optimization.
-
isRunning
public boolean isRunning()
Returnstrueif the optimization is running.- Returns:
trueif the optimization is running
-
isPaused
public boolean isPaused()
Returnstrueif the optimization is paused.- Returns:
trueif the optimization is paused
-
isStopped
public boolean isStopped()
Returnstrueif the optimization is stopped.- Returns:
trueif the optimization is stopped
-
isTerminated
public boolean isTerminated()
Returnstrueif the optimization is terminated.- Returns:
trueif the optimization is terminated
-
checkpoint
public void checkpoint() throws TerminationExceptionA checkpoint that checks for termination.- Throws:
TerminationException- if the optimization is terminated
-
checkpointStop
public void checkpointStop() throws TerminationException, StopExceptionA checkpoint that checks for termination and stop.- Throws:
TerminationException- if the optimization is terminatedStopException- if the optimization is stopped
-
getState
public Control.State getState()
Returns the state.- Returns:
- the state
-
setState
protected void setState(Control.State state)
Sets the state and invokes listeners if the state has changed.- Parameters:
state- the desired state
-
addListener
public void addListener(ControlListener listener)
Adds aControlListener.- Parameters:
listener- the listener to add- See Also:
removeListener(org.opt4j.core.optimizer.ControlListener)
-
removeListener
public void removeListener(ControlListener listener)
Removes aControlListener.- Parameters:
listener- the listener to remove- See Also:
addListener(org.opt4j.core.optimizer.ControlListener)
-
-