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
The Opt4JTask executes one optimization process.
See Also:
  • Field Details

    • 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:
  • Constructor Details

    • Opt4JTask

      @Inject public Opt4JTask()
      Constructs a Opt4JTask.
    • Opt4JTask

      public Opt4JTask(boolean closeOnStop)
      Constructs a Opt4JTask.
      Parameters:
      closeOnStop - close automatically after optimization
  • Method Details

    • execute

      public void execute() throws Exception
      Description copied from class: Task
      Executes the Task.
      Specified by:
      execute in class Task
      Throws:
      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(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(Optimizer optimizer, int iteration)
      Description copied from interface: OptimizerIterationListener
      Invoked if the Optimizer completes an iteration.
      Specified by:
      iterationComplete in interface OptimizerIterationListener
      Parameters:
      optimizer - the optimizer
      iteration - the completed iteration