Package org.opt4j.common.completer
Class ParallelIndividualCompleter
- java.lang.Object
-
- org.opt4j.common.completer.SequentialIndividualCompleter
-
- org.opt4j.common.completer.ParallelIndividualCompleter
-
- All Implemented Interfaces:
IndividualCompleter,OptimizerStateListener
public class ParallelIndividualCompleter extends SequentialIndividualCompleter implements OptimizerStateListener
TheParallelIndividualCompletercompletesIndividuals with multiple threads.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classParallelIndividualCompleter.CompleteTheParallelIndividualCompleter.Completeclass completes a singleIndividual.
-
Field Summary
Fields Modifier and Type Field Description protected ExecutorServiceexecutor-
Fields inherited from class org.opt4j.common.completer.SequentialIndividualCompleter
control, decoder, evaluator
-
-
Constructor Summary
Constructors Constructor Description ParallelIndividualCompleter(Control control, Decoder decoder, Evaluator evaluator, int maxThreads)Constructs aParallelIndividualCompleterwith a specified maximal number of concurrent threads.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomplete(Iterable<? extends Individual> iterable)Decodes and evaluates allIndividuals in theIterableif they are not already evaluated.protected voidfinalize()voidoptimizationStarted(Optimizer optimizer)Invoked if theOptimizerstarts the optimization process.voidoptimizationStopped(Optimizer optimizer)Invoked if theOptimizerstops the optimization process.protected voidshutdownExecutorService()Shutdown theExecutorService.-
Methods inherited from class org.opt4j.common.completer.SequentialIndividualCompleter
complete, decode, evaluate
-
-
-
-
Field Detail
-
executor
protected final ExecutorService executor
-
-
Constructor Detail
-
ParallelIndividualCompleter
@Inject public ParallelIndividualCompleter(Control control, Decoder decoder, Evaluator evaluator, int maxThreads)
Constructs aParallelIndividualCompleterwith a specified maximal number of concurrent threads.- Parameters:
control- the controldecoder- the decoderevaluator- the evaluatormaxThreads- the maximal number of parallel threads (using namespaceParallelIndividualCompleter)
-
-
Method Detail
-
complete
public void complete(Iterable<? extends Individual> iterable) throws TerminationException
Description copied from interface:IndividualCompleterDecodes and evaluates allIndividuals in theIterableif they are not already evaluated.- Specified by:
completein interfaceIndividualCompleter- Overrides:
completein classSequentialIndividualCompleter- Parameters:
iterable- the set of individuals to be completed- Throws:
TerminationException- if the optimization is terminated
-
finalize
protected void finalize() throws Throwable
-
shutdownExecutorService
protected void shutdownExecutorService()
Shutdown theExecutorService.
-
optimizationStarted
public void optimizationStarted(Optimizer optimizer)
Description copied from interface:OptimizerStateListenerInvoked if theOptimizerstarts the optimization process.- Specified by:
optimizationStartedin interfaceOptimizerStateListener- Parameters:
optimizer- the optimizer
-
optimizationStopped
public void optimizationStopped(Optimizer optimizer)
Description copied from interface:OptimizerStateListenerInvoked if theOptimizerstops the optimization process.- Specified by:
optimizationStoppedin interfaceOptimizerStateListener- Parameters:
optimizer- the optimizer
-
-