LSSolution Class¶
-
class
localsolver::
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: LSSolutionStatus
Summary¶
setValue |
Sets the value of the given expression in this solution. |
setIntValue |
Sets the value of the given expression in this solution. |
setDoubleValue |
Sets the value of the given expression in this solution. |
getValue |
Returns the value of the given expression in this solution. |
getDoubleValue |
Returns the value of the given expression in this solution. |
isViolated |
Returns true if the given expression is violated in this solution. |
isUndefined |
Returns true if the given expression has an undefined value in this solution. |
getIntValue |
Returns the value of the given expression in this solution. |
getCollectionValue |
Returns the value of the given expression in this solution. |
getArrayValue |
Returns the value of the given expression in this solution. |
getStatus |
Returns the status of the solution. |
clear |
Clear the solution and set all decisions to zero. |
Functions¶
-
void
setValue
(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 or S_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 as setIntValue.
See: See: See: Parameters: - expr - Decision.
- value - Value assigned to the decision in this solution.
-
void
setValue
(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 or S_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 as setDoubleValue.
See: See: Parameters: - expr - Decision.
- value - Value assigned to the decision in this solution.
-
void
setIntValue
(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 or S_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.
See: See: Since: 3.0
Parameters: - expr - Decision.
- value - Value assigned to the decision in this solution.
-
void
setDoubleValue
(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 or S_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.
See: See: Since: 3.0
Parameters: - expr - Decision.
- value - Value assigned to the decision in this solution.
-
lsint
getValue
(const LSExpression expr)¶ Returns the value of the given expression in this solution.
Only allowed in states S_Paused or S_Stopped. Only allowed if this expression is an integer or a boolean.
See: LSExpression::isInt() See: LSExpression::isBool() Return: Value of the expression in this solution. Parameters: expr - Expression.
-
lsdouble
getDoubleValue
(const LSExpression expr)¶ Returns the value of the given expression in this solution.
Only allowed in states S_Paused or S_Stopped. Only allowed if this expression is a double.
See: LSExpression::isDouble() Return: Value of the expression in this solution. Since: 3.0 Parameters: expr - Expression.
-
bool
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 (NotANumber)
- 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 or S_Stopped.
Return: True if this expression is violated in this solution. Since: 5.5 See: isUndefined() Parameters: expr - Expression.
-
bool
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 or S_Stopped.
Return: True if this expression has an undefined value in this solution. Since: 7.0 Parameters: expr - Expression.
-
lsint
getIntValue
(const LSExpression expr)¶ Returns the value of the given expression in this solution.
Only allowed in states S_Paused or S_Stopped. Only allowed if this expression is an integer or a boolean.
See: LSExpression::isInt() See: LSExpression::isBool() Return: Value of the expression in this solution. Since: 3.0 Parameters: expr - Expression.
-
LSCollection
getCollectionValue
(const LSExpression expr)¶ Returns the value of the given expression in this solution.
Only allowed in states S_Paused or S_Stopped. Only allowed if this expression is a collection (list).
See: LSExpression::isCollection() Return: Value of the expression in this solution. Since: 5.5 Parameters: expr - Expression.
-
LSArray
getArrayValue
(const LSExpression expr)¶ Returns the value of the given expression in this solution.
Only allowed in states S_Paused or S_Stopped. Only allowed if this expression is an array.
See: LSExpression::isArray() Return: Value of the expression in this solution. Since: 7.5 Parameters: expr - Expression.
-
LSSolutionStatus
getStatus
()¶ Returns the status of the solution.
Only allowed in states S_Paused or S_Stopped.
Return: Status of the solution. See: LSSolutionStatus