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).
Summary¶
Returns the value of the given expression in this solution. |
|
Sets the value of the given expression in this solution. |
|
Clear the solution and set all decisions to zero. |
Fields¶
- HxSolution.status¶
Status of the solution. Only allowed in states
PAUSED
orSTOPPED
. The returned value can be one of the following strings:INCONSISTENT
: Solution and model are inconsistent. The solver was able to prove that the model admits no feasible solution. Note that even a model without any constraint can be inconsistent, because some computations can yield undefined results. For instance, computing,SQRT(x)
with negative x yields an undefined value, which causes the solution to be invalid if it is used in an objective or a constraint (directly or indirectly).INFEASIBLE
: Solution is infeasible (some constraints are violated).FEASIBLE
: Solution is feasible but optimality was not proven.OPTIMAL
: Solution is optimal (all objective bounds are reached).
- Return type:
a string among
INCONSISTENT
,INFEASIBLE
,FEASIBLE
orOPTIMAL
.
- HxSolution.objectiveBounds¶
Bounds computed by the solver for all objectives. This field returns a readonly map-like structure with the following features:
A count field e.g.
objectiveBounds.count()
. This count field is always equal to the number of objectives present in the model.An overloaded index
[]
operator to get a bound for a specific objective, e.g.objectiveBounds[0]
. The index must be between0
andobjectiveBounds.count() - 1
. Accessing a value outside these bounds throws an exception.An overloaded
iterator
operator to iterate over the objective bounds with afor
statement.
If the solver has never been launched or if no bound was found for a particular objective, an infinite or a very large number is returned.
Only allowed in states
PAUSED
orSTOPPED
.- Return type:
map-like structure containing numbers (integers or doubles).
- HxSolution.objectiveGaps¶
Gaps computed by the solver for all objectives. This field returns a readonly map-like structure with the following features:
A count field e.g.
objectiveGaps.count()
. This count field is always equal to the number of objectives present in the model.An overloaded index
[]
operator to get a bound for a specific objective, e.g.objectiveGaps[0]
. The index must be between0
andobjectiveGaps.count() - 1
. Accessing a value outside these bounds throws an exception.An overloaded
iterator
operator to iterate over the objective gaps with afor
statement.
The gap is defined as:
\[|obj - bound| / \max(1, |obj|, |bound|)\]Only allowed in states
PAUSED
orSTOPPED
.- Return type:
map-like structure containing doubles.
Methods¶
- HxSolution.getValue(expression)¶
Returns the value of the given expression in this solution. The type of the returned value depends on the type of the expression. It can be a number if the expression has an integer or double value, an array if the expression is an array, or a collection if the expression is a list or a set decision.
Only allowed in states
PAUSED
orSTOPPED
.- Parameters:
expression – Expression for which you want the value
- Return type:
a number, an array or a collection depending on the type of the expression.
- HxSolution.setValue(expression, value)¶
Sets the value of the given expression in this solution. Only decisions can be set. The value must be an integer or a double depending on the type of the decision to set. If you want to modify the decisions of type collection (set or list), you should directly modify the collection returned by the method
getValue()
.If the solver was not launched, this value will be used as an initial value for the decision. Only allowed in state
STOPPED
.- Parameters:
expr – Decision.
value – Value assigned to the decision in this solution.
- HxSolution.clear()¶
Clear the solution and set all decisions to zero. Only allowed in state
STOPPED
.