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
TheOpt4JTaskexecutes 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 booleancloseOnStopprotected booleaninitializingprotected com.google.inject.Injectorinjectorprotected booleanisClosedprotected Optimizeroptimizerprotected com.google.inject.InjectorparentInjector
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the task.voidexecute()Executes theTask.protected com.google.inject.InjectorgetInjector()Returns theInjectorof the task.<O> OgetInstance(Class<O> type)Returns the instance of the given class.intgetIteration()Returns the current iteration.protected OptimizergetOptimizer()Returns theOptimizerof the task.voidinit(com.google.inject.Injector injector)Initialize with a parentInjector.voiditerationComplete(Optimizer optimizer, int iteration)Invoked if theOptimizercompletes an iteration.voidopen()Initialize a task manually before executing it.voidstateChanged(Control.State state)Invoked if the state of theControlchanges.-
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 ExceptionDescription copied from class:TaskExecutes 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 theInjectorof the task.- Returns:
- the injector
-
getOptimizer
protected Optimizer getOptimizer()
Returns theOptimizerof the task.- Returns:
- the optimizer
-
stateChanged
public void stateChanged(Control.State state)
Description copied from interface:ControlListenerInvoked if the state of theControlchanges.- Specified by:
stateChangedin interfaceControlListener- Parameters:
state- the current state of the optimization process
-
iterationComplete
public void iterationComplete(Optimizer optimizer, int iteration)
Description copied from interface:OptimizerIterationListenerInvoked if theOptimizercompletes an iteration.- Specified by:
iterationCompletein interfaceOptimizerIterationListener- Parameters:
optimizer- the optimizeriteration- the completed iteration
-
-