Package com.hexaly.optimizer
Class HxSolution
java.lang.Object
com.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 Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the solution and set all decisions to zero.booleangetArrayValue(HxExpression expr) Gets the value of this expression in the best solution found by the optimizer.Returns the value of the given expression in this solution.doublegetDoubleObjectiveBound(int objectiveIndex) Returns the bound computed by the optimizer for the given objective.doublegetDoubleValue(HxExpression expr) Returns the value of the given expression in this solution.getIntervalValue(HxExpression expr) Returns the value of the given expression in this solution.longgetIntObjectiveBound(int objectiveIndex) Returns the bound computed by the optimizer for the given objective.longgetIntValue(HxExpression expr) Returns the value of the given expression in this solution.longgetObjectiveBound(int objectiveIndex) Returns the bound computed by the optimizer for the given objective.doublegetObjectiveGap(int objectiveIndex) Returns the gap computed by the optimizer for the given objective.Returns the Hexaly Optimizer object associated to this solution.Returns the status of the solution.longgetValue(HxExpression expr) Returns the value of the given expression in this solution.inthashCode()booleanisUndefined(HxExpression expr) Returns true if the given expression has an undefined value in this solution.booleanisViolated(HxExpression expr) Returns true if the given expression is violated in this solution.voidsetDoubleValue(HxExpression expr, double value) Sets the value of the given expression in this solution.voidsetIntervalValue(HxExpression expr, HxInterval value) Sets the value of the given expression in this solution.voidsetIntValue(HxExpression expr, long value) Sets the value of the given expression in this solution.voidsetValue(HxExpression expr, double value) Sets the value of the given expression in this solution.voidsetValue(HxExpression expr, long value) Sets the value of the given expression in this solution.voidsetValue(HxExpression expr, HxInterval value) Sets the value of the given expression in this solution.
-
Method Details
-
getOptimizer
Returns the Hexaly Optimizer object associated to this solution.- Returns:
- Hexaly Optimizer object.
-
setValue
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in stateHxState.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 assetIntValue(com.hexaly.optimizer.HxExpression, long).- Parameters:
expr- Decision.value- Value assigned to the decision in this solution.- See Also:
-
setValue
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in stateHxState.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 assetDoubleValue(com.hexaly.optimizer.HxExpression, double).- Parameters:
expr- Decision.value- Value assigned to the decision in this solution.- See Also:
-
setValue
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in stateHxState.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 assetIntervalValue(com.hexaly.optimizer.HxExpression, com.hexaly.optimizer.HxInterval).- Parameters:
expr- Decision.value- Value assigned to the decision in this solution.- See Also:
-
setIntValue
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in stateHxState.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.- Since:
- 3.0
- See Also:
-
setDoubleValue
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in stateHxState.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.- Since:
- 3.0
- See Also:
-
setIntervalValue
Sets the value of the given expression in this solution. Only decisions can be set. Only allowed in stateHxState.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.- Since:
- 3.0
- See Also:
-
getValue
Returns the value of the given expression in this solution. Only allowed in statesHxState.PausedorHxState.Stopped. Only allowed if this expression is an integer or a boolean. This method has the same behavior asgetIntValue(HxExpression).- Parameters:
expr- Expression.- Returns:
- Value of the expression in this solution.
- See Also:
-
getDoubleValue
Returns the value of the given expression in this solution. Only allowed in statesHxState.PausedorHxState.Stopped. Only allowed if this expression is a double.- Parameters:
expr- Expression.- Returns:
- Value of the expression in this solution.
- Since:
- 3.0
- See Also:
-
getIntValue
Returns the value of the given expression in this solution. Only allowed in statesHxState.PausedorHxState.Stopped. Only allowed if this expression is an integer or a boolean.- Parameters:
expr- Expression.- Returns:
- Value of the expression in this solution.
- Since:
- 3.0
- See Also:
-
getIntervalValue
Returns the value of the given expression in this solution. Only allowed in statesHxState.PausedorHxState.Stopped. Only allowed if this expression is an interval.- Parameters:
expr- Expression.- Returns:
- Value of the expression in this solution.
- Since:
- 12.0
- See Also:
-
getCollectionValue
Returns the value of the given expression in this solution. Only allowed in statesHxState.PausedorHxState.Stopped. Only allowed if this expression is a collection (list or set).- Parameters:
expr- Expression.- Returns:
- Value of the expression in this solution.
- Since:
- 5.5
- See Also:
-
getArrayValue
Gets the value of this expression in the best solution found by the optimizer. Only allowed in statesHxState.PausedorHxState.Stopped. Only allowed if this expression is an array.- Returns:
- Value in the best solution.
- Since:
- 7.5
- See Also:
-
isViolated
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).
HxState.PausedorHxState.Stopped.- Parameters:
expr- Expression.- Returns:
- True if this expression is violated in this solution.
- Since:
- 5.5
-
isUndefined
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).
HxState.PausedorHxState.Stopped.- Parameters:
expr- Expression.- Returns:
- True if this expression has an undefined value in this solution.
- Since:
- 7.0
-
getStatus
Returns the status of the solution. Only allowed in statesHxState.PausedorHxState.Stopped.- Returns:
- Status of the solution.
- See Also:
-
getObjectiveBound
public long 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.MIN_VALUE or Long.MAX_VALUE depending on the optimization direction of the objective. Only allowed in statesHxState.PausedorHxState.Stopped. Only allowed if this expression is an integer or a boolean. This method has the same behavior asgetIntObjectiveBound(int).- Parameters:
objectiveIndex- Index of the objective.- Returns:
- Bound of the given objective.
- Since:
- 8.5
- See Also:
-
getIntObjectiveBound
public long 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.MIN_VALUE or Long.MAX_VALUE depending on the optimization direction of the objective. Only allowed in statesHxState.PausedorHxState.Stopped. Only allowed if this expression is an integer or a boolean.- Parameters:
objectiveIndex- Index of the objective.- Returns:
- Bound of the given objective.
- Since:
- 8.5
- See Also:
-
getDoubleObjectiveBound
public double getDoubleObjectiveBound(int objectiveIndex) Returns the bound computed by the optimizer for the given objective. If the optimizer has never been launched, this method returns Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY depending on the optimization direction of the objective. Only allowed in statesHxState.PausedorHxState.Stopped. Only allowed if this expression is a double.- Parameters:
objectiveIndex- Index of the objective.- Returns:
- Bound of the given objective.
- Since:
- 8.5
- See Also:
-
getObjectiveGap
public double 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 statesHxState.PausedorHxState.Stopped.- Parameters:
objectiveIndex- Index of the objective.- Returns:
- Gap of the given objective.
-
clear
public void clear()Clears the solution and set all decisions to zero. Only allowed in stateHxState.Stopped. -
hashCode
public int hashCode() -
equals
-