LSSolution Class¶
-
class LSSolution¶
Solution to the optimization model. A solution carries the values of all expressions in the model. It is used to retrieve the values of all expressions (getting the solution), or to set the values of some decisions (setting the solution).
- See
Summary¶
Sets the value of the given expression in this solution. |
|
Sets the value of the given expression in this solution. |
|
Sets the value of the given expression in this solution. |
|
Sets the value of the given expression in this solution. |
|
Returns the value of the given expression in this solution. |
|
Returns the value of the given expression in this solution. |
|
Returns true if the given expression is violated in this solution. |
|
Returns true if the given expression has an undefined value in this solution. |
|
Returns the value of the given expression in this solution. |
|
Returns the value of the given expression in this solution. |
|
Returns the value of the given expression in this solution. |
|
Returns the status of the solution. |
|
Returns the bound computed by the solver for the given objective. |
|
Returns the bound computed by the solver for the given objective. |
|
Returns the bound computed by the solver for the given objective. |
|
Returns the gap computed by the solver for the given objective. |
|
Clear the solution and set all decisions to zero. |
Functions¶
-
void LSSolution::setValue(const LSExpression &expr, lsint value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
S_Paused
orS_Stopped
. Only allowed if this expression is an integer or a boolean. If the solver was not launched, this value will be used as an initial value for the decision. This method has the same behavior asLSSolution::setIntValue()
.- Parameters
expr – Decision.
value – Value assigned to the decision in this solution.
- See
- See
- See
-
void LSSolution::setValue(const LSExpression &expr, lsdouble value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
S_Paused
orS_Stopped
. Only allowed if this expression is a double. If the solver was not launched, this value will be used as an initial value for the decision. This method has the same behavior asLSSolution::setDoubleValue()
.- Parameters
expr – Decision.
value – Value assigned to the decision in this solution.
- See
- See
-
void LSSolution::setIntValue(const LSExpression &expr, lsint value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
S_Paused
orS_Stopped
. Only allowed if this expression is an integer or a boolean. If the solver was not launched, this value will be used as an initial value for the decision.- Parameters
expr – Decision.
value – Value assigned to the decision in this solution.
- See
- See
- Since
3.0
-
void LSSolution::setDoubleValue(const LSExpression &expr, lsdouble value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
S_Paused
orS_Stopped
. If the solver was not launched, this value will be used as an initial value for the decision. Only allowed if this expression is a double.- Parameters
expr – Decision.
value – Value assigned to the decision in this solution.
- See
- See
- Since
3.0
-
lsint LSSolution::getValue(const LSExpression &expr)¶
Returns the value of the given expression in this solution. Only allowed in states
S_Paused
orS_Stopped
. Only allowed if this expression is an integer or a boolean. This method has the same behavior asLSSolution::getIntValue()
.- Parameters
expr – Expression.
- See
- See
- Returns
Value of the expression in this solution.
-
lsdouble LSSolution::getDoubleValue(const LSExpression &expr)¶
Returns the value of the given expression in this solution. Only allowed in states
S_Paused
orS_Stopped
. Only allowed if this expression is a double.- Parameters
expr – Expression.
- See
- Returns
Value of the expression in this solution.
- Since
3.0
-
bool LSSolution::isViolated(const LSExpression &expr)¶
Returns true if the given expression is violated in this solution. An expression can be violated in 3 cases:
it is a constraint and its value is 0
it is a a double objective and its value is NaN (not a number)
it is a constraint with no valid value (arithmetic or out of bounds exception or NaN operands).
Note that only constraints and objectives can be violated. Other expression can have undefined value provided that it does not impact a constraint or objective.
Only allowed in states
S_Paused
orS_Stopped
.- Parameters
expr – Expression.
- Returns
True if this expression is violated in this solution.
- Since
5.5
- See
-
bool LSSolution::isUndefined(const LSExpression &expr)¶
Returns true if the given expression has an undefined value in this solution. An expression can be undefined in 2 cases:
it is a a double and its value is NaN (NotANumber)
it is an integer or boolean with no valid value (arithmetic or out of bounds exception).
Only allowed in states
S_Paused
orS_Stopped
.- Parameters
expr – Expression.
- Returns
True if this expression has an undefined value in this solution.
- Since
7.0
-
lsint LSSolution::getIntValue(const LSExpression &expr)¶
Returns the value of the given expression in this solution. Only allowed in states
S_Paused
orS_Stopped
. Only allowed if this expression is an integer or a boolean.- Parameters
expr – Expression.
- See
- See
- Returns
Value of the expression in this solution.
- Since
3.0
-
LSCollection LSSolution::getCollectionValue(const LSExpression &expr)¶
Returns the value of the given expression in this solution. Only allowed in states
S_Paused
orS_Stopped
. Only allowed if this expression is a collection (list or set).- Parameters
expr – Expression.
- See
- Returns
Value of the expression in this solution.
- Since
5.5
-
LSArray LSSolution::getArrayValue(const LSExpression &expr)¶
Returns the value of the given expression in this solution. Only allowed in states
S_Paused
orS_Stopped
. Only allowed if this expression is an array.- Parameters
expr – Expression.
- See
- Returns
Value of the expression in this solution.
- Since
7.5
-
LSSolutionStatus LSSolution::getStatus()¶
Returns the status of the solution. Only allowed in states
S_Paused
orS_Stopped
.- Returns
Status of the solution.
- See
LSSolutionStatus
-
lsint LSSolution::getObjectiveBound(int objectiveIndex)¶
Returns the bound computed by the solver for the given objective. If the solver has never been launched, this method returns LONG_LONG_MIN or LONG_LONG_MAX depending on the optimization direction of the objective. Only allowed in states
S_Paused
orS_Stopped
. Only allowed if this expression is an integer or a boolean. This method has the same behavior asLSSolution::getIntObjectiveBound()
.- Parameters
objectiveIndex – Index of the objective.
- Returns
Bound of the given objective.
- See
- See
- Since
8.5
-
lsint LSSolution::getIntObjectiveBound(int objectiveIndex)¶
Returns the bound computed by the solver for the given objective. If the solver has never been launched, this method returns LONG_LONG_MIN or LONG_LONG_MAX depending on the optimization direction of the objective. Only allowed in states
S_Paused
orS_Stopped
. Only allowed if this expression is an integer or a boolean.- Parameters
objectiveIndex – Index of the objective.
- Returns
Bound of the given objective.
- See
- See
- Since
8.5
-
lsdouble LSSolution::getDoubleObjectiveBound(int objectiveIndex)¶
Returns the bound computed by the solver for the given objective. If the solver has never been launched, this method returns INFINITY or -INFINITY depending on the optimization direction of the objective. Only allowed in states
S_Paused
orS_Stopped
. Only allowed if this expression is a double.- Parameters
objectiveIndex – Index of the objective.
- Returns
Bound of the given objective.
- See
- Since
8.5
-
lsdouble LSSolution::getObjectiveGap(int objectiveIndex)¶
Returns the gap computed by the solver for the given objective. It is defined as:
\[|obj - bound| / \max(1, |obj|, |bound|)\]Only allowed in states
S_Paused
orS_Stopped
.- Parameters
objectiveIndex – Index of the objective.
- Returns
Gap of the given objective.
-
void LSSolution::clear()¶
Clear the solution and set all decisions to zero. Only allowed in state
S_Stopped
.