Package org.moeaframework.parallel
Class FutureSolution
java.lang.Object
org.moeaframework.core.Solution
org.moeaframework.parallel.FutureSolution
- All Implemented Interfaces:
Serializable
,Displayable
,Formattable<Solution>
Represents a
Solution
evaluated asynchronously. Calls to methods requiring the evaluated results, such as
getObjectives()
, will block until the asynchronous evaluation completes. This behavior is achieved by
assigning a Future
through the setFuture(Future)
method prior to submitting this solution for
evaluation.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncopy()
Returns an independent copy of this solution.getAttribute
(String key) Returns the value of the attribute that is associated with the specified key, ornull
if no value has been associated with the key.Returns theMap
containing this solution's attributes.double
getConstraint
(int index) Returns the constraint at the specified index.double[]
Returns an array containing the constraints of this solution.long
Returns the unique identifier for this solution.double
getObjective
(int index) Returns the objective at the specified index.double[]
Returns an array containing the objectives of this solution.boolean
hasAttribute
(String key) Returnstrue
if the specified key exists in this solution's attributes;false
otherwise.boolean
Returnstrue
if any of the constraints are violated;false
otherwise.Methods inherited from class org.moeaframework.core.Solution
addAttributes, asTabularData, chebyshevDistance, clearAttributes, deepCopy, distanceToNearestSolution, distanceToNearestSolution, euclideanDistance, getNumberOfConstraints, getNumberOfObjectives, getNumberOfVariables, getSumOfConstraintViolations, getVariable, isFeasible, manhattanDistance, removeAttribute, setAttribute, setConstraint, setConstraints, setObjective, setObjectives, setVariable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.moeaframework.util.format.Displayable
display
-
Method Details
-
getDistributedEvaluationID
public long getDistributedEvaluationID()Returns the unique identifier for this solution. This can be used to:- Configure the random number generator (RNG) seed on stochastic problems, allowing reproducible results.
- Tracking files or other resources associated with the solution, such as writing program inputs to disk.
- Returns:
- the unique identifier that was associated with this solution
-
copy
Description copied from class:Solution
Returns an independent copy of this solution. It is required thatx.copy()
is completely independent fromx
. This means any method invoked onx.copy()
in no way alters the state ofx
and vice versa. It is typically the case thatx.copy().getClass() == x.getClass()
andx.copy().equals(x)
Note that a solution's attributes are not copied, as the attributes are generally specific to each instance.
-
getObjectives
public double[] getObjectives()Description copied from class:Solution
Returns an array containing the objectives of this solution. Modifying the returned array will not modify the internal state of this solution.- Overrides:
getObjectives
in classSolution
- Returns:
- an array containing the objectives of this solution
-
getConstraints
public double[] getConstraints()Description copied from class:Solution
Returns an array containing the constraints of this solution. Modifying the returned array will not modify the internal state of this solution.- Overrides:
getConstraints
in classSolution
- Returns:
- an array containing the constraints of this solution
-
getObjective
public double getObjective(int index) Description copied from class:Solution
Returns the objective at the specified index.- Overrides:
getObjective
in classSolution
- Parameters:
index
- index of the objective to return- Returns:
- the objective at the specified index
-
getConstraint
public double getConstraint(int index) Description copied from class:Solution
Returns the constraint at the specified index.- Overrides:
getConstraint
in classSolution
- Parameters:
index
- index of the variable to be returned- Returns:
- the constraint at the specified index
-
violatesConstraints
public boolean violatesConstraints()Description copied from class:Solution
Returnstrue
if any of the constraints are violated;false
otherwise. This is the opposite ofSolution.isFeasible()
.- Overrides:
violatesConstraints
in classSolution
- Returns:
true
if any of the constraints are violated;false
otherwise
-
getAttribute
Description copied from class:Solution
Returns the value of the attribute that is associated with the specified key, ornull
if no value has been associated with the key.- Overrides:
getAttribute
in classSolution
- Parameters:
key
- the key whose associated value is to be returned- Returns:
- the value associated with the specified key, or
null
if no value has been associated with the key
-
hasAttribute
Description copied from class:Solution
Returnstrue
if the specified key exists in this solution's attributes;false
otherwise.- Overrides:
hasAttribute
in classSolution
- Parameters:
key
- the key whose presence is being tested- Returns:
true
if the specified key exists in this solution's attributes;false
otherwise
-
getAttributes
Description copied from class:Solution
Returns theMap
containing this solution's attributes.- Overrides:
getAttributes
in classSolution
- Returns:
- the
Map
containing this solution's attributes
-