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
TheParallelIndividualCompleter
completesIndividual
s with multiple threads.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
ParallelIndividualCompleter.Complete
TheParallelIndividualCompleter.Complete
class completes a singleIndividual
.
-
Field Summary
Fields Modifier and Type Field Description protected ExecutorService
executor
-
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 aParallelIndividualCompleter
with a specified maximal number of concurrent threads.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
complete(Iterable<? extends Individual> iterable)
Decodes and evaluates allIndividual
s in theIterable
if they are not already evaluated.protected void
finalize()
void
optimizationStarted(Optimizer optimizer)
Invoked if theOptimizer
starts the optimization process.void
optimizationStopped(Optimizer optimizer)
Invoked if theOptimizer
stops the optimization process.protected void
shutdownExecutorService()
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 aParallelIndividualCompleter
with 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:IndividualCompleter
Decodes and evaluates allIndividual
s in theIterable
if they are not already evaluated.- Specified by:
complete
in interfaceIndividualCompleter
- Overrides:
complete
in 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:OptimizerStateListener
Invoked if theOptimizer
starts the optimization process.- Specified by:
optimizationStarted
in interfaceOptimizerStateListener
- Parameters:
optimizer
- the optimizer
-
optimizationStopped
public void optimizationStopped(Optimizer optimizer)
Description copied from interface:OptimizerStateListener
Invoked if theOptimizer
stops the optimization process.- Specified by:
optimizationStopped
in interfaceOptimizerStateListener
- Parameters:
optimizer
- the optimizer
-
-