HxSolution Class¶
- class Hexaly.Optimizer.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¶
Returns the Hexaly Optimizer object associated to 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 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 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. |
Instance methods¶
- HexalyOptimizer GetOptimizer()¶
Returns the Hexaly Optimizer object associated to this solution.
- Returns:
Hexaly Optimizer object
- Return type:
- void SetValue(HxExpression expr, long value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
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
HxSolution.SetIntValue
.- Arguments:
expr (HxExpression) – Decision.
value (long) – Value assigned to the decision in this solution.
- See:
- See:
- See:
- void SetValue(HxExpression expr, double value)
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
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
HxSolution.SetDoubleValue
.- Arguments:
expr (HxExpression) – Decision.
value (double) – Value assigned to the decision in this solution.
- See:
- See:
- void SetValue(HxExpression expr, HxInterval value)
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
Stopped
. Only allowed if this expression is an interval. 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
HxSolution.SetIntervalValue
.- Arguments:
expr (HxExpression) – Decision.
value (HxInterval) – Value assigned to the decision in this solution.
- See:
- See:
- void SetIntValue(HxExpression expr, long value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
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.- Since:
3.0
- Arguments:
expr (HxExpression) – Decision.
value (long) – Value assigned to the decision in this solution.
- See:
- See:
- See:
- void SetDoubleValue(HxExpression expr, long value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
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.- Since:
3.0
- Arguments:
expr (HxExpression) – Decision.
value (long) – Value assigned to the decision in this solution.
- See:
- See:
- void SetIntervalValue(HxExpression expr, HxInterval value)¶
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in state
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 an interval.- Since:
12.0
- Arguments:
expr (HxExpression) – Decision.
value (HxInterval) – Value assigned to the decision in this solution.
- See:
- See:
- long GetValue(HxExpression expr)¶
Returns the value of the given expression in this solution. Only allowed in states
Paused
orStopped
. Only allowed if this expression is an integer or a boolean.This method has the same behavior as
HxSolution.GetIntValue
.- Arguments:
expr (HxExpression) – Expression.
- Returns:
Value of the expression in this solution.
- Return type:
long
- See:
- See:
- double GetDoubleValue(HxExpression expr)¶
Returns the value of the given expression in this solution. Only allowed in states
Paused
orStopped
. Only allowed if this expression is a double.- Since:
3.0
- Arguments:
expr (HxExpression) – Expression.
- Returns:
Value of the expression in this solution.
- Return type:
double
- See:
- long GetIntValue(HxExpression expr)¶
Returns the value of the given expression in this solution. Only allowed in states
Paused
orStopped
. Only allowed if this expression is an integer or a boolean.- Since:
3.0
- Arguments:
expr (HxExpression) – Expression.
- Returns:
Value of the expression in this solution.
- Return type:
long
- See:
- See:
- long GetIntervalValue(HxExpression expr)¶
Returns the value of the given expression in this solution. Only allowed in states
Paused
orStopped
. Only allowed if this expression is an interval.- Since:
3.0
- Arguments:
expr (HxExpression) – Expression.
- Returns:
Value of the expression in this solution.
- Return type:
- See:
- HxCollection GetCollectionValue(HxExpression expr)¶
Returns the value of the given expression in this solution. Only allowed in states
Paused
orStopped
. Only allowed if this expression is a collection (list or set).- Since:
5.5
- Arguments:
expr (HxExpression) – Expression.
- Returns:
Value of the expression in this solution.
- Return type:
- See:
- HxCollection GetArrayValue(HxExpression expr)¶
Returns the value of the given expression in this solution. Only allowed in states
Paused
orStopped
. Only allowed if this expression is an array.- Since:
7.5
- Arguments:
expr (HxExpression) – Expression.
- Returns:
Value of the expression in this solution.
- Return type:
- See:
- bool IsViolated(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 and its value is NaN (Not A Number).
It is an integer or boolean with no valid value (arithmetic or out of bounds exception).
Only allowed in states
Paused
orStopped
.- Since:
5.5
- Arguments:
expr (HxExpression) – Expression.
- Returns:
True if the expression is violated in this solution.
- Return type:
bool
- bool IsUndefined(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
Paused
orStopped
.- Since:
7.0
- Arguments:
expr (HxExpression) – Expression.
- Returns:
True if this expression has an undefined value in this solution.
- HxSolutionStatus GetStatus()¶
Returns the status of the solution. Only allowed in states
Paused
orStopped
.- Returns:
Status of the solution
- Return type:
- long GetObjectiveBound(int objectiveIndex)¶
Returns the bound computed by the solver for the given objective. If the solver has never been launched, this method returns Int64.MaxValue or Int64.MinValue depending on the optimization direction of the objective. Only allowed in states
Paused
orStopped
. Only allowed if this expression is a boolean or an integer. This method has the same behavior asHxSolution.GetIntObjectiveBound
.- Since:
8.5
- Arguments:
objectiveIndex (int) – Index of the objective.
- Returns:
Bound of the given objective.
- Return type:
long
- See:
- See:
- long GetIntObjectiveBound(int objectiveIndex)¶
Returns the bound computed by the solver for the given objective. If the solver has never been launched, this method returns Int64.MaxValue or Int64.MinValue depending on the optimization direction of the objective. Only allowed in states
Paused
orStopped
. Only allowed if this expression is a boolean or an integer.- Since:
8.5
- Arguments:
objectiveIndex (int) – Index of the objective.
- Returns:
Bound of the given objective.
- Return type:
long
- See:
- See:
- double GetDoubleObjectiveBound(int objectiveIndex)¶
Returns the bound computed by the solver for the given objective. If the solver has never been launched, this method returns Double.PositiveInfinity or Double.NegativeInfinity depending on the optimization direction of the objective. Only allowed in states
Paused
orStopped
. Only allowed if this expression is a double.- Since:
8.5
- Arguments:
objectiveIndex (int) – Index of the objective.
- Returns:
Bound of the given objective.
- Return type:
double
- See:
- double GetObjectiveGap(int objectiveIndex)¶
Returns the gap computed by the solver 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
Paused
orStopped
.- Arguments:
objectiveIndex (int) – Index of the objective.
- Returns:
Gap of the given objective.
- Return type:
double