8.7.2. Solution attributes¶
MDO_REAL_ATTR_SOLUTION_TIME |
The solution time, in seconds. |
|
MDO_REAL_ATTR_PRESOLVER_TIME |
The presolve time, in seconds. |
|
MDO_REAL_ATTR_SOLVER_TIME |
The solver time, in seconds. |
|
MDO_INT_ATTR_HAS_SOLUTION |
Indicates whether the optimization solution is available. |
|
MDO_INT_ATTR_HAS_PRIMAL_RAY |
Indicates whether the primal ray is available. |
|
MDO_INT_ATTR_HAS_DUAL_RAY |
Whether the dual ray is available. |
|
MDO_REAL_ATTR_PRIMAL_OBJ_VAL |
The primal object value. |
|
MDO_REAL_ATTR_DUAL_OBJ_VAL |
The dual object value. |
|
MDO_REAL_ATTR_PRIMAL_SOLN |
The primal solution. |
|
MDO_REAL_ATTR_DUAL_SOLN |
The dual solution. |
|
MDO_INT_ATTR_COL_BASIS |
The basis of the primal solution. |
|
MDO_INT_ATTR_ROW_BASIS |
The basis of the dual solution. |
|
MDO_REAL_ATTR_ACTIVITY |
The value of the primal activity. |
|
MDO_REAL_ATTR_REDUCED_COST |
The value of reduced costs. |
|
MDO_REAL_ATTR_SYM_MAT_PRIMAL_SOLN |
The values of primal block variable. |
|
MDO_REAL_ATTR_MIP_GAP_ABS |
The abs of the GAP of MIP solution. |
|
MDO_REAL_ATTR_MIP_GAP_REL |
The relative GAP of the MILP solution. |
Note
Note that any change to the optimization model after solving will clear all information about solution attributes. In this case, you need to perform solving again to obtain the solution attributes of the new model. The parameter APIs of C++, Java, and Python are in the MDO_INT_PARAM namespace, please refer to the Chapter Alias of Attributes.
8.7.2.1. “SolutionTime”¶
This attribute is used to query the total time consumed in optimization solving, in seconds.
Group: Solution
Type: Real
Modifiable: No
Examples
C
Mdo_getRealAttr(model, "SolutionTime", &solution_time);C++
solution_time = model.getRealAttr("SolutionTime");Python
solution_time = model.get_real_attr("SolutionTime")
8.7.2.2. “PresolverTime”¶
This attribute is used to query the presolve time used for optimization, in seconds.
Group: Solution
Type: Real
Modifiable: No
Examples
C
Mdo_getRealAttr(model, "PresolverTime", &presolve_time);C++
presolve_time = model.getRealAttr("PresolverTime");Python
presolve_time = model.get_real_attr("PresolverTime")
8.7.2.3. “SolverTime”¶
This attribute is used to query the solver time used for optimization, in seconds.
Group: Solution
Type: Real
Modifiable: No
Examples
C
Mdo_getRealAttr(model, "SolverTime", &solver_time);C++
solver_time = model.getRealAttr("SolverTime");Python
solver_time = model.get_real_attr("SolverTime")
8.7.2.4. “HasSolution”¶
This attribute is used to query whether the optimization solution is available.
Group: Solution
Type: Integer
Modifiable: No
Value |
Description |
---|---|
0 |
Unavailable |
1 |
Available |
Examples
C
Mdo_getIntAttr(model, "HasSolution", &has_solution);C++
has_solution = model.getIntAttr("HasSolution");Python
has_solution = model.get_int_attr("HasSolution")
8.7.2.5. “HasPrimalRay”¶
This attribute is used to query whether the primal ray is available.
Group: Solution
Type: Integer
Modifiable: No
Value |
Description |
---|---|
0 |
Unavailable |
1 |
Available |
Examples
C
Mdo_getIntAttr(model, "HasPrimalRay", &has_primal_ray);C++
has_primal_ray = model.getIntAttr("HasPrimalRay");Python
has_primal_ray = model.get_int_attr("HasPrimalRay")
8.7.2.6. “HasDualRay”¶
This attribute is used to check if an unbounded ray of the dual is available.
Group: Solution
Type: Integer
Modifiable: No
Value |
Description |
---|---|
0 |
Unavailable |
1 |
Available |
Examples
C
Mdo_getIntAttr(model, "HasDualRay", &has_dual_ray);C++
has_dual_ray = model.getIntAttr("HasDualRay");Python
has_dual_ray = model.get_int_attr("HasDualRay")
8.7.2.7. “PrimalObjVal”¶
This attribute is used to query the primal object value.
Group: Solution
Type: Real
Modifiable: No
Examples
C
Mdo_getRealAttr(model, "PrimalObjVal", &primal_obj_val);C++
primal_obj_val = model.getRealAttr("PrimalObjVal");Python
primal_obj_val = model.get_real_attr("PrimalObjVal")
8.7.2.8. “DualObjVal”¶
This attribute is used to query the dual object value.
Group: Solution
Type: Real
Modifiable: No
Examples
C
Mdo_getRealAttr(model, "DualObjVal", &dual_obj_val);C++
dual_obj_val = model.getRealAttr("DualObjVal");Python
dual_obj_val = model.get_real_attr("DualObjVal")
8.7.2.9. “PrimalSoln”¶
This attribute is used to query the current primal solution.
Group: Model
Type: Real
Modifiable: No
Examples
C
Mdo_getRealAttrIndex(model, "PrimalSoln", 0, &primal_soln); Mdo_getRealAttrArray(model, "PrimalSoln", 0, 4, primal_soln_array);C++
primal_soln = model.getRealAttrIndex("PrimalSoln", 0); primal_soln_array = model.getRealAttrArray("PrimalSoln", 0, 4); primal_soln = var.getRealAttr("PrimalSoln");Python
primal_soln = model.get_real_attr_index("PrimalSoln", 0) primal_soln_array = model.get_real_attr_array("PrimalSoln", 0, 4) primal_soln = var.get_real_attr("PrimalSoln")
8.7.2.10. “DualSoln”¶
This attribute is used to query the current dual solution.
Group: Model
Type: Real
Modifiable: No
Examples
C
Mdo_getRealAttrIndex(model, "DualSoln", 0, &dual_soln); Mdo_getRealAttrArray(model, "DualSoln", 0, 4, dual_soln_array);C++
dual_soln = model.getRealAttrIndex("DualSoln", 0); dual_soln_array = model.getRealAttrArray("DualSoln", 0, 4); dual_soln = cons.getRealAttr("DualSoln");Python
dual_soln = model.get_real_attr_index("DualSoln", 0) dual_soln_array = model.get_real_attr_array("DualSoln", 0, 4) dual_soln = cons.get_real_attr("DualSoln")
8.7.2.11. “ColBasis”¶
This attribute is used to set and query the status of the basis of a primal variable in the simplex method. Status of the basis and the corresponding values are as follows:
isFree = 0, basic = 1, atUpperBound = 2, atLowerBound = 3, superBasic = 4, isFixed = 5,
Group: Model
Type: Int
Modifiable: Yes
Examples
C
Mdo_setIntAttrIndex(model, "ColBasis", 0, 1); Mdo_setIntAttrArray(model, "ColBasis", 0, 4, col_basis_array); Mdo_getIntAttrIndex(model, "ColBasis", 0, &col_basis); Mdo_getIntAttrArray(model, "ColBasis", 0, 4, col_basis_array);C++
model.setIntAttrIndex("ColBasis", 0, 1); model.setIntAttrArray("ColBasis", 0, 4, col_basis_array); col_basis = model.getIntAttrIndex("ColBasis", 0); col_basis_array = model.getIntAttrArray("ColBasis", 0, 4); var.setIntAttr("ColBasis", 1); col_basis = var.getIntAttr("ColBasis");Python
model.set_int_attr_index("ColBasis", 0, 1) model.set_int_attr_array("ColBasis", 0, 4, col_basis_array) col_basis = model.get_int_attr_index("ColBasis", 0) col_basis_array = model.get_int_attr_array("ColBasis", 0, 4) var.set_int_attr("ColBasis", 1) col_basis = var.get_int_attr("ColBasis")
8.7.2.12. “RowBasis”¶
This attribute is used to set and query the status of the basis of a dual variable in the simplex method. Status of the basis and the corresponding values are as follows:
isFree = 0, basic = 1, atUpperBound = 2, atLowerBound = 3, superBasic = 4, isFixed = 5,
Group: Model
Type: Int
Modifiable: No
Examples
C
Mdo_setIntAttrIndex(model, "RowBasis", 0, 1); Mdo_setIntAttrArray(model, "RowBasis", 0, 4, row_basis_array); Mdo_getIntAttrIndex(model, "RowBasis", 0, &row_basis); Mdo_getIntAttrArray(model, "RowBasis", 0, 4, row_basis_array);C++
model.setIntAttrIndex("RowBasis", 0, 1); model.setIntAttrArray("RowBasis", 0, 4, row_basis_array); row_basis = model.getIntAttrIndex("RowBasis", 0); row_basis_array = model.getIntAttrArray("RowBasis", 0, 4); cons.setIntAttr("RowBasis", 1); row_basis = cons.getIntAttr("RowBasis");Python
model.set_int_attr_index("RowBasis", 0, 1) model.set_int_attr_array("RowBasis", 0, 4, row_basis_array) row_basis = model.get_int_attr_index("RowBasis", 0) row_basis_array = model.get_int_attr_array("RowBasis", 0, 4) cons.set_int_attr("RowBasis", 1) row_basis = cons.get_int_attr("RowBasis")
8.7.2.13. “Activity”¶
This attribute is used to query the value in the current primal activity. Take the problem in Modeling for linear programming as an example. The definition of primal activity is as follows:
Group: Model
Type: Real
Modifiable: No
Examples
C
Mdo_getRealAttrIndex(model, "Activity", 0, &activity); Mdo_getRealAttrArray(model, "Activity", 0, 4, activity_array);C++
activity = model.getRealAttrIndex("Activity", 0); activity_array = model.getRealAttrArray("Activity", 0, 4); activity = cons.getRealAttr("Activity");Python
activity = model.get_real_attr_index("Activity", 0) activity_array = model.get_real_attr_array("Activity", 0, 4) activity = cons.get_real_attr("Activity")
8.7.2.14. “ReducedCost”¶
This attribute is used to query the value in the current reduced costs. Take the problem in Modeling for linear programming as an example. The definition of reduced costs is as follows:
\(y\) is the value of the dual variable.
Group: Model
Type: Real
Modifiable: No
Examples
C
Mdo_getRealAttrIndex(model, "ReducedCost", 0, &reduced_cost); Mdo_getRealAttrArray(model, "ReducedCost", 0, 4, reduced_cost_array);C++
reduced_cost = model.getRealAttrIndex("ReducedCost", 0); reduced_cost_array = model.getRealAttrArray("ReducedCost", 0, 4); reduced_cost = var.getRealAttr("ReducedCost");Python
reduced_cost = model.get_real_attr_index("ReducedCost", 0) reduced_cost_array = model.get_real_attr_array("ReducedCost", 0, 4) reduced_cost = var.get_real_attr("ReducedCost")
8.7.2.15. “SymMatPrimalSoln”¶
This attribute is used to query the primal solutions of corresponding block variables.
Group: Model
Type: Real
Modifiable: No
Examples
C
MDO_CHECK_CALL(Mdo_getRealAttrSymMat(model, "SymMatPrimalSoln", 0, dim_mat * dim_mat, NULL, NULL, soln));C++
soln = model.getRealAttrSymMat("SymMatPrimalSoln", b, dim_mats[b] * dim_mats[b], NULL, NULL);Python
soln = model.get_real_attr_sym_mat("SymMatPrimalSoln", 0, [i * 2 + j for i in range(2) for j in range(2)], [j * 2 + i for i in range(2) for j in range(2)])
8.7.2.16. “MIP/GapAbs”¶
This attribute is used to query the abs value of the gap for MIP solution.
Group: Solution
Type: Real
Modifiable: No
Examples
C
Mdo_getRealAttr(model, "MIP/GapAbs", &mip_gap_abs);C++
mip_gap_abs = model.getRealAttr("MIP/GapAbs");Python
mip_gap_abs = model.get_real_attr("MIP/GapAbs")
8.7.2.17. “MIP/GapRel”¶
This attribute is used to query the relative gap for MIP solution.
Group: Solution
Type: Real
Modifiable: No
Examples
C
Mdo_getRealAttr(model, "MIP/GapRel", &mip_gap_rel);C++
mip_gap_rel = model.getRealAttr("MIP/GapRel");Python
mip_gap_rel = model.get_real_attr("MIP/GapRel")