org.opt4j.core.optimizer
Class Control

java.lang.Object
  extended by org.opt4j.core.optimizer.Control

public class Control
extends java.lang.Object

The Control allows to pause, stop, and terminate, the optimization process.

The Optimizer calls the methods

in which the process might get paused, terminated (by the TerminationException) or stopped (by the StopException). By definition, a StopException might get thrown only between iterations, a TerminationException also within an iteration of the optimization algorithm. In this context, the optimization algorithm calls checkpointStop() between the iterations and checkpoint() within the iteration.


Nested Class Summary
static class Control.State
          The Control.State of the control.
 
Field Summary
protected  java.util.Set<ControlListener> listeners
           
protected  Control.State state
           
 
Constructor Summary
Control()
           
 
Method Summary
 void addListener(ControlListener listener)
          Adds a ControlListener.
 void checkpoint()
          A checkpoint that checks for termination.
 void checkpointStop()
          A checkpoint that checks for termination and stop.
 void doPause()
          Pauses the optimization.
 void doStart()
          Starts the optimization.
 void doStop()
          Stops the optimization.
 void doTerminate()
          Terminates the optimization.
 Control.State getState()
          Returns the state.
 boolean isPaused()
          Returns true if the optimization is paused.
 boolean isRunning()
          Returns true if the optimization is running.
 boolean isStopped()
          Returns true if the optimization is stopped.
 boolean isTerminated()
          Returns true if the optimization is terminated.
 void removeListener(ControlListener listener)
          Removes a ControlListener.
protected  void setState(Control.State state)
          Sets the state and invokes listeners if the state has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

state

protected Control.State state

listeners

protected final java.util.Set<ControlListener> listeners
Constructor Detail

Control

public Control()
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()
Returns true if the optimization is running.

Returns:
true if the optimization is running

isPaused

public boolean isPaused()
Returns true if the optimization is paused.

Returns:
true if the optimization is paused

isStopped

public boolean isStopped()
Returns true if the optimization is stopped.

Returns:
true if the optimization is stopped

isTerminated

public boolean isTerminated()
Returns true if the optimization is terminated.

Returns:
true if the optimization is terminated

checkpoint

public void checkpoint()
                throws TerminationException
A checkpoint that checks for termination.

Throws:
TerminationException - if the optimization is terminated

checkpointStop

public void checkpointStop()
                    throws TerminationException,
                           StopException
A checkpoint that checks for termination and stop.

Throws:
TerminationException - if the optimization is terminated
StopException - 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 a ControlListener.

Parameters:
listener - the listener to add
See Also:
removeListener(org.opt4j.core.optimizer.ControlListener)

removeListener

public void removeListener(ControlListener listener)
Removes a ControlListener.

Parameters:
listener - the listener to remove
See Also:
addListener(org.opt4j.core.optimizer.ControlListener)