|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Objectorg.moeaframework.core.Solution
public class Solution
A solution to an optimization problem, storing the decision variables,
objectives, constraints and attributes. Attributes are arbitrary (key, value) pairs; they are instance-specific and are not carried over in
the copy constructor.
Solutions should only be constructed in Problem.newSolution() or
cloned from an existing solution with copy(). This ensures the
solutions and configured correctly for the given optimization problem.
| Constructor Summary | |
|---|---|
|
Solution(double[] objectives)
Constructs a solution with no variables and the specified objectives. |
|
Solution(int numberOfVariables,
int numberOfObjectives)
Constructs a solution with the specified number of variables and objectives with no constraints. |
|
Solution(int numberOfVariables,
int numberOfObjectives,
int numberOfConstraints)
Constructs a solution with the specified number of variables, objectives and constraints. |
protected |
Solution(Solution solution)
Copy constructor. |
| Method Summary | |
|---|---|
void |
addAttributes(Map<String,Object> attributes)
Adds all attributes to this solution in the specified Map. |
void |
clearAttributes()
Removes all keys and values from this solution's attributes. |
Solution |
copy()
Returns an independent copy of this solution. |
Object |
getAttribute(String key)
Returns the value of the attribute that is associated with the specified key, or null if no value has been associated with the key. |
Map<String,Serializable> |
getAttributes()
Returns the Map containing this solution's attributes. |
double |
getConstraint(int index)
Returns the constraint at the specified index. |
double[] |
getConstraints()
Returns an array containing the constraints of this solution. |
int |
getNumberOfConstraints()
Returns the number of constraints defined by this solution. |
int |
getNumberOfObjectives()
Returns the number of objectives defined by this solution. |
int |
getNumberOfVariables()
Returns the number of variables defined by this solution. |
double |
getObjective(int index)
Returns the objective at the specified index. |
double[] |
getObjectives()
Returns an array containing the objectives of this solution. |
Variable |
getVariable(int index)
Returns the variable at the specified index. |
boolean |
hasAttribute(String key)
Returns true if the specified key exists in this solution's
attributes; false otherwise. |
Object |
removeAttribute(String key)
Removes the specified key and its associated value from this solution. |
Object |
setAttribute(String key,
Serializable value)
Associates the specified value with the specified key. |
void |
setConstraint(int index,
double constraint)
Sets the constraint at the specified index. |
void |
setConstraints(double[] constraints)
Sets all constraints of this solution. |
void |
setObjective(int index,
double objective)
Sets the objective at the specified index. |
void |
setObjectives(double[] objectives)
Sets all objectives of this solution. |
void |
setVariable(int index,
Variable variable)
Sets the variable at the specified index. |
boolean |
violatesConstraints()
Returns true if any of the constraints are violated;
false otherwise. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Solution(int numberOfVariables,
int numberOfObjectives)
numberOfVariables - the number of variables defined by this solutionnumberOfObjectives - the number of objectives defined by this
solution
public Solution(int numberOfVariables,
int numberOfObjectives,
int numberOfConstraints)
numberOfVariables - the number of variables defined by this solutionnumberOfObjectives - the number of objectives defined by this
solutionnumberOfConstraints - the number of constraints defined by this
solutionpublic Solution(double[] objectives)
objectives - the objectives to be stored in this solutionprotected Solution(Solution solution)
solution - the solution being copied| Method Detail |
|---|
public Solution copy()
x.copy() is completely independent from x . This means
any method invoked on x.copy() in no way alters the state of
x and vice versa. It is typically the case that
x.copy().getClass() == x.getClass() and
x.copy().equals(x)
Note that a solution's attributes are not copied, as the attributes are generally specific to each instance.
public int getNumberOfObjectives()
public int getNumberOfVariables()
public int getNumberOfConstraints()
public double getObjective(int index)
index - index of the objective to return
IndexOutOfBoundsException - if the index is out of range
(index < 0) || (index >= getNumberOfObjectives())public Variable getVariable(int index)
index - index of the variable to return
IndexOutOfBoundsException - if the index is out of range
(index < 0) || (index >= getNumberOfVariables())
public void setObjective(int index,
double objective)
index - index of the objective to setobjective - the new value of the objective being set
IndexOutOfBoundsException - if the index is out of range
(index < 0) || (index >= getNumberOfObjectives())public void setObjectives(double[] objectives)
objectives - the new objectives for this solution
IllegalArgumentException - if objectives.length !=
getNumberOfObjectives()public double[] getObjectives()
public void setVariable(int index,
Variable variable)
index - index of the variable being setvariable - the new value of the variable being set
IndexOutOfBoundsException - if the index is out of range
(index < 0) || (index >= getNumberOfVariables())public boolean violatesConstraints()
true if any of the constraints are violated;
false otherwise.
true if any of the constraints are violated;
false otherwisepublic double getConstraint(int index)
index - index of the variable to be returned
IndexOutOfBoundsException - if the index is out of range
(index < 0) || (index >= getNumberOfConstraints())public void setConstraints(double[] constraints)
constraints - the new constraints for this solution
IllegalArgumentException - if constraints.length !=
getNumberOfConstraints()public double[] getConstraints()
public void setConstraint(int index,
double constraint)
index - the index of the constraint being setconstraint - the new value of the constraint being set
IndexOutOfBoundsException - if the index is out of range
(index < 0) || (index >= getNumberOfConstraints())public Object getAttribute(String key)
null if no value has been associated with the key.
key - the key whose associated value is to be returned
null if
no value has been associated with the key
public Object setAttribute(String key,
Serializable value)
null if no prior value has been
associated with the key.
key - the key with which the specified value is to be associatedvalue - the value to be associated with the specified key
null if no
prior value has been associated with the keypublic Object removeAttribute(String key)
null if no
prior value has been associated with the key.
key - the key to be removed
null if no
prior value has been associated with the keypublic boolean hasAttribute(String key)
true if the specified key exists in this solution's
attributes; false otherwise.
key - the key whose presence is being tested
true if the specified key exists in this solution's
attributes; false otherwisepublic Map<String,Serializable> getAttributes()
Map containing this solution's attributes.
Map containing this solution's attributespublic void addAttributes(Map<String,Object> attributes)
Map.
attributes - the Map containing the attributes to be added
to this solutionpublic void clearAttributes()
|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||