org.opt4j.core.common.completer
Class ParallelIndividualCompleter

java.lang.Object
  extended by org.opt4j.core.common.completer.SequentialIndividualCompleter
      extended by org.opt4j.core.common.completer.ParallelIndividualCompleter
All Implemented Interfaces:
IndividualCompleter, OptimizerStateListener

public class ParallelIndividualCompleter
extends SequentialIndividualCompleter
implements OptimizerStateListener

The ParallelIndividualCompleter completes Individuals with multiple threads.


Nested Class Summary
protected  class ParallelIndividualCompleter.Complete
          The ParallelIndividualCompleter.Complete class completes a single Individual.
 
Field Summary
protected  java.util.concurrent.ExecutorService executor
           
 
Fields inherited from class org.opt4j.core.common.completer.SequentialIndividualCompleter
control, decoder, evaluator
 
Constructor Summary
ParallelIndividualCompleter(Control control, Decoder<Genotype,java.lang.Object> decoder, Evaluator<java.lang.Object> evaluator, int maxThreads)
          Constructs a ParallelIndividualCompleter with a specified maximal number of concurrent threads.
 
Method Summary
 void complete(java.lang.Iterable<? extends Individual> iterable)
          Decodes and evaluates all Individuals in the Iterable if they are not already evaluated.
protected  void finalize()
           
 void optimizationStarted(Optimizer optimizer)
          Invoked if the Optimizer starts the optimization process.
 void optimizationStopped(Optimizer optimizer)
          Invoked if the Optimizer stops the optimization process.
protected  void shutdownExecutorService()
          Shutdown the ExecutorService.
 
Methods inherited from class org.opt4j.core.common.completer.SequentialIndividualCompleter
complete, decode, evaluate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

executor

protected final java.util.concurrent.ExecutorService executor
Constructor Detail

ParallelIndividualCompleter

@Inject
public ParallelIndividualCompleter(Control control,
                                          Decoder<Genotype,java.lang.Object> decoder,
                                          Evaluator<java.lang.Object> evaluator,
                                          int maxThreads)
Constructs a ParallelIndividualCompleter with a specified maximal number of concurrent threads.

Parameters:
control - the control
decoder - the decoder
evaluator - the evaluator
maxThreads - the maximal number of parallel threads (using namespace ParallelIndividualCompleter)
Method Detail

complete

public void complete(java.lang.Iterable<? extends Individual> iterable)
              throws TerminationException
Description copied from interface: IndividualCompleter
Decodes and evaluates all Individuals in the Iterable if they are not already evaluated.

Specified by:
complete in interface IndividualCompleter
Overrides:
complete in class SequentialIndividualCompleter
Parameters:
iterable - the set of individuals to be completed
Throws:
TerminationException - if the optimization is terminated

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

shutdownExecutorService

protected void shutdownExecutorService()
Shutdown the ExecutorService.


optimizationStarted

public void optimizationStarted(Optimizer optimizer)
Description copied from interface: OptimizerStateListener
Invoked if the Optimizer starts the optimization process.

Specified by:
optimizationStarted in interface OptimizerStateListener
Parameters:
optimizer - the optimizer

optimizationStopped

public void optimizationStopped(Optimizer optimizer)
Description copied from interface: OptimizerStateListener
Invoked if the Optimizer stops the optimization process.

Specified by:
optimizationStopped in interface OptimizerStateListener
Parameters:
optimizer - the optimizer