Package org.moeaframework.parallel
Class FutureSolution
java.lang.Object
org.moeaframework.core.Solution
org.moeaframework.parallel.FutureSolution
- All Implemented Interfaces:
Serializable,Copyable<Solution>,Displayable,Formattable<Solution>
Represents a
Solution evaluated asynchronously. Calls to methods requiring the evaluated results, such as
getObjectiveValues(), 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, ornullif no value has been associated with the key.Returns theMapcontaining this solution's attributes.getConstraint(int index) Returns the constraint at the specified index.doublegetConstraintValue(int index) Returns the constraint value at the specified index.double[]Returns an array containing the constraint values of this solution.longReturns the unique identifier for this solution.getObjective(int index) Returns the objective at the specified index.doublegetObjectiveValue(int index) Returns the objective value at the specified index.double[]Returns an array containing the objective values of this solution.booleanhasAttribute(String key) Returnstrueif the specified key exists in this solution's attributes;falseotherwise.booleanReturnstrueif any of the constraints are violated;falseotherwise.Methods inherited from class org.moeaframework.core.Solution
addAttributes, asTabularData, chebyshevDistance, clearAttributes, deepCopy, distanceToNearestSolution, distanceToNearestSolution, euclideanDistance, getCanonicalObjectiveValues, getNumberOfConstraints, getNumberOfObjectives, getNumberOfVariables, getSumOfConstraintViolations, getVariable, isFeasible, manhattanDistance, removeAttribute, setAttribute, setConstraint, setConstraints, setConstraintValue, setConstraintValues, setObjective, setObjectives, setObjectiveValue, setObjectiveValues, setVariableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:SolutionReturns 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 ofxand 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.
-
getObjectiveValues
public double[] getObjectiveValues()Description copied from class:SolutionReturns an array containing the objective values of this solution. Modifying the returned array will not modify the internal state of this solution.- Overrides:
getObjectiveValuesin classSolution- Returns:
- an array containing the objective values of this solution
-
getConstraintValues
public double[] getConstraintValues()Description copied from class:SolutionReturns an array containing the constraint values of this solution. Modifying the returned array will not modify the internal state of this solution.- Overrides:
getConstraintValuesin classSolution- Returns:
- an array containing the constraint values of this solution
-
getObjectiveValue
public double getObjectiveValue(int index) Description copied from class:SolutionReturns the objective value at the specified index.- Overrides:
getObjectiveValuein classSolution- Parameters:
index- index of the objective to return- Returns:
- the objective value at the specified index
-
getConstraintValue
public double getConstraintValue(int index) Description copied from class:SolutionReturns the constraint value at the specified index.- Overrides:
getConstraintValuein classSolution- Parameters:
index- index of the variable to be returned- Returns:
- the constraint value at the specified index
-
getObjective
Description copied from class:SolutionReturns the objective at the specified index.- Overrides:
getObjectivein classSolution- Parameters:
index- index of the objective to return- Returns:
- the objective at the specified index
-
getConstraint
Description copied from class:SolutionReturns the constraint at the specified index.- Overrides:
getConstraintin 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:SolutionReturnstrueif any of the constraints are violated;falseotherwise. This is the opposite ofSolution.isFeasible().- Overrides:
violatesConstraintsin classSolution- Returns:
trueif any of the constraints are violated;falseotherwise
-
getAttribute
Description copied from class:SolutionReturns the value of the attribute that is associated with the specified key, ornullif no value has been associated with the key.- Overrides:
getAttributein classSolution- Parameters:
key- the key whose associated value is to be returned- Returns:
- the value associated with the specified key, or
nullif no value has been associated with the key
-
hasAttribute
Description copied from class:SolutionReturnstrueif the specified key exists in this solution's attributes;falseotherwise.- Overrides:
hasAttributein classSolution- Parameters:
key- the key whose presence is being tested- Returns:
trueif the specified key exists in this solution's attributes;falseotherwise
-
getAttributes
Description copied from class:SolutionReturns theMapcontaining this solution's attributes.- Overrides:
getAttributesin classSolution- Returns:
- the
Mapcontaining this solution's attributes
-