HxSolution Class¶
-
class HxSolution¶
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. |
|
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 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 optimizer for the given objective. |
|
Returns the bound computed by the optimizer for the given objective. |
|
Returns the bound computed by the optimizer for the given objective. |
|
Returns the gap computed by the optimizer for the given objective. |
|
Clear the solution and set all decisions to zero. |
Functions¶
-
void HxSolution::setValue(const HxExpression &expr, hxint value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
S_Stopped
. Only allowed if this expression is an integer or a boolean. If the optimizer was not launched, this value will be used as an initial value for the decision. This method has the same behavior asHxSolution::setIntValue()
.- Parameters:
expr – Decision.
value – Value assigned to the decision in this solution.
- See:
- See:
- See:
-
void HxSolution::setValue(const HxExpression &expr, hxdouble value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
S_Stopped
. Only allowed if this expression is a double. If the optimizer was not launched, this value will be used as an initial value for the decision. This method has the same behavior asHxSolution::setDoubleValue()
.- Parameters:
expr – Decision.
value – Value assigned to the decision in this solution.
- See:
- See:
-
void HxSolution::setValue(const HxExpression &expr, HxInterval value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
S_Stopped
. Only allowed if this expression is an interval. If the optimizer was not launched, this value will be used as an initial value for the decision. This method has the same behavior asHxSolution::setIntervalValue()
.- Parameters:
expr – Decision.
value – Value assigned to the decision in this solution.
- See:
- See:
-
void HxSolution::setIntValue(const HxExpression &expr, hxint value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
S_Stopped
. Only allowed if this expression is an integer or a boolean. If the optimizer 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 HxSolution::setDoubleValue(const HxExpression &expr, hxdouble value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
S_Stopped
. If the optimizer 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
-
void HxSolution::setIntervalValue(const HxExpression &expr, HxInterval value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
S_Stopped
. If the optimizer was not launched, this value will be used as an initial value for the decision. Only allowed if this expression is an interval.- Parameters:
expr – Decision.
value – Value assigned to the decision in this solution.
- See:
- See:
- Since:
12.0
-
hxint HxSolution::getValue(const HxExpression &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 asHxSolution::getIntValue()
.- Parameters:
expr – Expression.
- See:
- See:
- Returns:
Value of the expression in this solution.
-
hxdouble HxSolution::getDoubleValue(const HxExpression &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
-
HxInterval HxSolution::getIntervalValue(const HxExpression &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 interval.- Parameters:
expr – Expression.
- See:
- Returns:
Value of the expression in this solution.
- Since:
12.0
-
bool HxSolution::isViolated(const HxExpression &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 double objective and its value is NaN (Not a Number)
it is an integer or boolean 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 HxSolution::isUndefined(const HxExpression &expr)¶
Returns true if the given expression has an undefined value in this solution. An expression can be undefined in 4 cases:
It is a double and its value is NaN (Not a Number).
It is an integer or boolean with no valid value (arithmetic or out of bounds exception).
It is an interval with at least one undefined bound.
It is the result of any ill-defined operation (at with out of bounds index or operations on undefined values for instance).
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
-
hxint HxSolution::getIntValue(const HxExpression &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
-
HxCollection HxSolution::getCollectionValue(const HxExpression &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
-
HxArray HxSolution::getArrayValue(const HxExpression &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
-
HxSolutionStatus HxSolution::getStatus()¶
Returns the status of the solution. Only allowed in states
S_Paused
orS_Stopped
.- Returns:
Status of the solution.
- See:
HxSolutionStatus
-
hxint HxSolution::getObjectiveBound(int objectiveIndex)¶
Returns the bound computed by the optimizer for the given objective. If the optimizer 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 asHxSolution::getIntObjectiveBound()
.- Parameters:
objectiveIndex – Index of the objective.
- Returns:
Bound of the given objective.
- See:
- See:
- Since:
8.5
-
hxint HxSolution::getIntObjectiveBound(int objectiveIndex)¶
Returns the bound computed by the optimizer for the given objective. If the optimizer 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
-
hxdouble HxSolution::getDoubleObjectiveBound(int objectiveIndex)¶
Returns the bound computed by the optimizer for the given objective. If the optimizer 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
-
hxdouble HxSolution::getObjectiveGap(int objectiveIndex)¶
Returns the gap computed by the optimizer for the given objective. The gap for feasible solutions is defined as:
\[|obj - bound| / \max(1, |obj|, |bound|)\]Infeasible solutions have an infinite gap.
Only allowed in states
S_Paused
orS_Stopped
.- Parameters:
objectiveIndex – Index of the objective.
- Returns:
Gap of the given objective.
-
void HxSolution::clear()¶
Clear the solution and set all decisions to zero. Only allowed in state
S_Stopped
.