org.opt4j.core.start
Class Opt4JTask

java.lang.Object
  extended by org.opt4j.core.config.Task
      extended by org.opt4j.core.start.Opt4JTask
All Implemented Interfaces:
java.util.concurrent.Callable<java.lang.Void>, ControlListener, OptimizerIterationListener

public class Opt4JTask
extends Task
implements ControlListener, OptimizerIterationListener

The Opt4JTask executes one optimization process.

See Also:
Task

Nested Class Summary
 
Nested classes/interfaces inherited from class org.opt4j.core.config.Task
Task.State
 
Field Summary
protected  boolean closeOnStop
           
protected  com.google.inject.Injector injector
           
protected  boolean isClosed
           
protected  Optimizer optimizer
           
protected  com.google.inject.Injector parentInjector
           
 
Fields inherited from class org.opt4j.core.config.Task
e, isInit, listeners, modules, state
 
Constructor Summary
Opt4JTask()
          Constructs a Opt4JTask.
Opt4JTask(boolean closeOnStop)
          Constructs a Opt4JTask.
 
Method Summary
 void close()
          Close the task.
 void execute()
          Executes the Task.
protected  com.google.inject.Injector getInjector()
          Returns the Injector of the task.
<O> O
getInstance(java.lang.Class<O> type)
          Returns the instance of the given class.
 int getIteration()
          Returns the current iteration.
protected  Optimizer getOptimizer()
          Returns the Optimizer of the task.
 void init(com.google.inject.Injector injector)
          Initialize with a parent Injector.
 void iterationComplete(int iteration)
          Invoked if the Optimizer completes an iteration.
 void open()
          Initialize a task manually before executing it.
 void stateChanged(Control.State state)
          Invoked if the state of the Control changes.
 
Methods inherited from class org.opt4j.core.config.Task
addStateListener, call, getException, getModules, getState, init, init, removeStateListener, setState, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

optimizer

protected Optimizer optimizer

injector

protected com.google.inject.Injector injector

parentInjector

protected com.google.inject.Injector parentInjector

closeOnStop

protected final boolean closeOnStop

isClosed

protected boolean isClosed
Constructor Detail

Opt4JTask

@Inject
public Opt4JTask()
Constructs a Opt4JTask.


Opt4JTask

public Opt4JTask(boolean closeOnStop)
Constructs a Opt4JTask.

Parameters:
closeOnStop - close automatically after optimization
Method Detail

execute

public void execute()
             throws java.lang.Exception
Description copied from class: Task
Executes the Task.

Specified by:
execute in class Task
Throws:
java.lang.Exception

init

public void init(com.google.inject.Injector injector)
Initialize with a parent Injector.

Parameters:
injector - the parent injector

close

public void close()
Close the task.


open

public void open()
Initialize a task manually before executing it. This enables to get instances of classes before the optimization starts.


getIteration

public int getIteration()
Returns the current iteration.

Returns:
the current iteration

getInstance

public <O> O getInstance(java.lang.Class<O> type)
Returns the instance of the given class.

Type Parameters:
O - the type of class
Parameters:
type - the class
Returns:
the instance of the class

getInjector

protected com.google.inject.Injector getInjector()
Returns the Injector of the task.

Returns:
the injector

getOptimizer

protected Optimizer getOptimizer()
Returns the Optimizer of the task.

Returns:
the optimizer

stateChanged

public void stateChanged(Control.State state)
Description copied from interface: ControlListener
Invoked if the state of the Control changes.

Specified by:
stateChanged in interface ControlListener
Parameters:
state - the current state of the optimization process

iterationComplete

public void iterationComplete(int iteration)
Description copied from interface: OptimizerIterationListener
Invoked if the Optimizer completes an iteration.

Specified by:
iterationComplete in interface OptimizerIterationListener
Parameters:
iteration - the completed iteration