public class DistributedProblem extends ProblemWrapper
evaluate(Solution)
method across multiple threads,
cores or compute nodes using the provided ExecutorService
. The
ExecutorService
defines the type and method of distribution. The
problem must be Serializable
if executing on remote nodes.problem
Constructor and Description |
---|
DistributedProblem(Problem problem,
java.util.concurrent.ExecutorService executor)
Decorates a problem for distributing the evaluation of the problem across
multiple threads, cores or compute nodes as defined by the specified
ExecutorService . |
DistributedProblem(Problem problem,
java.util.concurrent.ExecutorService executor,
boolean shutdownWhenClosed)
Decorates a problem for distributing the evaluation of the problem across
multiple threads, cores or compute nodes as defined by the specified
ExecutorService . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes any underlying resources used by this problem.
|
void |
evaluate(Solution solution)
Evaluates the solution, updating the solution's objectives in place.
|
static DistributedProblem |
from(Problem problem)
Creates a distributed problem using the number of available processors on
the local computer.
|
static DistributedProblem |
from(Problem problem,
int numberOfThreads)
Creates a distributed problem using a fixed number of threads.
|
Solution |
newSolution()
Returns a new solution for this problem.
|
getName, getNumberOfConstraints, getNumberOfObjectives, getNumberOfVariables
public DistributedProblem(Problem problem, java.util.concurrent.ExecutorService executor)
ExecutorService
. This will not shutdown the executor and is
equivalent to calling the constructor with shutdownWhenClosed
set to
false
.problem
- the problem being distributedexecutor
- the ExecutorService
for distributing jobs across
multiple threads, cores or compute nodespublic DistributedProblem(Problem problem, java.util.concurrent.ExecutorService executor, boolean shutdownWhenClosed)
ExecutorService
.problem
- the problem being distributedexecutor
- the ExecutorService
for distributing jobs across
multiple threads, cores or compute nodesshutdownWhenClosed
- true
to shutdown the executor when this
problem instance is closed; false
otherwisepublic static DistributedProblem from(Problem problem)
problem
- the problem to distributepublic static DistributedProblem from(Problem problem, int numberOfThreads)
problem
- the problem to distributenumberOfThreads
- the number of threadspublic void evaluate(Solution solution)
Problem
evaluate
in interface Problem
evaluate
in class ProblemWrapper
solution
- the solution to be evaluatedpublic Solution newSolution()
Problem
newSolution
in interface Problem
newSolution
in class ProblemWrapper
public void close()
Problem
close
in interface java.lang.AutoCloseable
close
in interface Problem
close
in class ProblemWrapper
Copyright 2009-2024 David Hadka and other contributors. All rights reserved.
Licensed under the GNU Lesser General Public License.
Return to the MOEA Framework homepage.