7.6.2. 解属性

参数

说明

“SolutionTime”

求解时间(以秒为单位)

“HasSolution”

指示优化解是否可用

“HasPrimalRay”

指示原始射线是否可用

“PrimalObjVal”

原始目标值

“DualObjVal”

对偶目标值

“PrimalSoln”

原始解

“DualSoln”

对偶解

“ColBasis”

原始解的基

“RowBasis”

对偶解的基

“Activity”

Primal activity 的值

“ReducedCost”

Reduced costs 的值

Note

需要注意的是,若在求解之后对优化模型进行任何改变,则解属性的相关信息将被全部清空,此时需要重新进行求解以获得新的模型的解属性。

7.6.2.1. “SolutionTime”

此属性用于查询优化求解使用的总时间(以秒为单位)

  • Group: Solution

  • Type: Real

  • Modifiable: No

示例

C

Mdo_getRealAttr(model, "SolutionTime", &solution_time);

C++

solution_time = model.getRealAttr("SolutionTime");

Python

solution_time = model.get_real_attr("SolutionTime")

7.6.2.2. “HasSolution”

此属性用于查询优化解是否可用

  • Group: Solution

  • Type: Integer

  • Modifiable: No

选项

说明

0

解不可用

1

解可用

示例

C

Mdo_getIntAttr(model, "HasSolution", &has_solution);

C++

has_solution = model.getIntAttr("HasSolution");

Python

has_solution = model.get_int_attr("HasSolution")

7.6.2.3. “HasPrimalRay”

此属性用于查询原始射线是否可用。

  • Group: Solution

  • Type: Integer

  • Modifiable: No

选项

说明

0

原始射线不可用

1

原始射线可用

示例

C

Mdo_getIntAttr(model, "HasPrimalRay", &has_primal_ray);

C++

has_primal_ray = model.getIntAttr("HasPrimalRay");

Python

has_primal_ray = model.get_int_attr("HasPrimalRay")

7.6.2.4. “PrimalObjVal”

此属性用于查询原始目标值。

  • Group: Solution

  • Type: Real

  • Modifiable: No

示例

C

Mdo_getRealAttr(model, "PrimalObjVal", &primal_obj_val);

C++

primal_obj_val = model.getRealAttr("PrimalObjVal");

Python

primal_obj_val = model.get_real_attr("PrimalObjVal")

7.6.2.5. “DualObjVal”

此属性用于查询对偶目标值。

  • Group: Solution

  • Type: Real

  • Modifiable: No

示例

C

Mdo_getRealAttr(model, "DualObjVal", &dual_obj_val);

C++

dual_obj_val = model.getRealAttr("DualObjVal");

Python

dual_obj_val = model.get_real_attr("DualObjVal")

7.6.2.6. “PrimalSoln”

此属性用于查询当前原始解。

  • Group: Model

  • Type: Real

  • Modifiable: No

示例

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")

7.6.2.7. “DualSoln”

此属性用于查询当前对偶解。

  • Group: Model

  • Type: Real

  • Modifiable: No

示例

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")

7.6.2.8. “ColBasis”

此属性用于查询与设置原始变量的单纯形的基的状态。基的状态以及对应的值分别为:

isFree = 0,
basic = 1,
atUpperBound = 2,
atLowerBound = 3,
superBasic = 4,
isFixed = 5,
  • Group: Model

  • Type: Int

  • Modifiable: Yes

示例

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")

7.6.2.9. “RowBasis”

此属性用于查询与设置对偶变量的单纯形的基的状态。基的状态以及对应的值分别为:

isFree = 0,
basic = 1,
atUpperBound = 2,
atLowerBound = 3,
superBasic = 4,
isFixed = 5,
  • Group: Model

  • Type: Int

  • Modifiable: No

示例

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")

7.6.2.10. “Activity”

此属性用于查询当前 primal activities 中的值。 以 线性规划建模 中的问题为例,primal activity 定义为:

\[A \cdot x.\]
  • Group: Model

  • Type: Real

  • Modifiable: No

示例

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")

7.6.2.11. “ReducedCost”

此属性用于查询当前 reduced costs 中的值。 以 线性规划建模 中的问题为例,reduced costs 定义为:

\[c - A^\top \cdot y.\]

其中 \(y\) 是对偶变量的值。

  • Group: Model

  • Type: Real

  • Modifiable: No

示例

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")