Package org.opt4j.start
Class Opt4JTask
- java.lang.Object
-
- org.opt4j.config.Task
-
- org.opt4j.start.Opt4JTask
-
- All Implemented Interfaces:
Callable<Void>
,ControlListener
,OptimizerIterationListener
public class Opt4JTask extends Task implements ControlListener, OptimizerIterationListener
TheOpt4JTask
executes one optimization process.- See Also:
Task
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opt4j.config.Task
Task.State
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
closeOnStop
protected boolean
initializing
protected com.google.inject.Injector
injector
protected boolean
isClosed
protected Optimizer
optimizer
protected com.google.inject.Injector
parentInjector
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the task.void
execute()
Executes theTask
.protected com.google.inject.Injector
getInjector()
Returns theInjector
of the task.<O> O
getInstance(Class<O> type)
Returns the instance of the given class.int
getIteration()
Returns the current iteration.protected Optimizer
getOptimizer()
Returns theOptimizer
of the task.void
init(com.google.inject.Injector injector)
Initialize with a parentInjector
.void
iterationComplete(Optimizer optimizer, int iteration)
Invoked if theOptimizer
completes an iteration.void
open()
Initialize a task manually before executing it.void
stateChanged(Control.State state)
Invoked if the state of theControl
changes.-
Methods inherited from class org.opt4j.config.Task
addStateListener, call, getException, getModules, getState, init, init, removeStateListener, setState, toString
-
-
-
-
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
-
initializing
protected final boolean initializing
- See Also:
- Constant Field Values
-
-
Method Detail
-
execute
public void execute() throws Exception
Description copied from class:Task
Executes theTask
.
-
init
public void init(com.google.inject.Injector injector)
Initialize with a parentInjector
.- 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(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 theInjector
of the task.- Returns:
- the injector
-
getOptimizer
protected Optimizer getOptimizer()
Returns theOptimizer
of the task.- Returns:
- the optimizer
-
stateChanged
public void stateChanged(Control.State state)
Description copied from interface:ControlListener
Invoked if the state of theControl
changes.- Specified by:
stateChanged
in interfaceControlListener
- Parameters:
state
- the current state of the optimization process
-
iterationComplete
public void iterationComplete(Optimizer optimizer, int iteration)
Description copied from interface:OptimizerIterationListener
Invoked if theOptimizer
completes an iteration.- Specified by:
iterationComplete
in interfaceOptimizerIterationListener
- Parameters:
optimizer
- the optimizeriteration
- the completed iteration
-
-