8.7.1. Model attributes¶
C API parameter |
Parameter |
Description |
---|---|---|
MDO_STR_ATTR_PROB_NAME |
The name of the optimized problem. |
|
MDO_INT_ATTR_MIN_SENSE |
Indicates whether the optimized problem is a minimization problem. |
|
MDO_REAL_ATTR_OBJ_CONST |
The constant offset of the target function. |
|
MDO_INT_ATTR_NUM_VARS |
The total number of variables in the model. |
|
MDO_INT_ATTR_NUM_CONSS |
The total number of constraints in the model. |
|
MDO_INT_ATTR_NUM_ENTS |
The total number of non-zero elements in the model. |
|
MDO_REAL_ATTR_LB |
The lower bound of a variable. |
|
MDO_REAL_ATTR_UB |
The upper bound of a variable. |
|
MDO_REAL_ATTR_OBJ |
The coefficient of variables in the target linear function. |
|
MDO_REAL_ATTR_LHS |
The lower bound (left-side value) of a constraint. |
|
MDO_REAL_ATTR_RHS |
The upper bound (right-side value) of a constraint. |
|
MDO_STR_ATTR_COL_NAME |
The name of a variable (column). |
|
MDO_STR_ATTR_ROW_NAME |
The name of a constraint (row). |
|
MDO_INT_ATTR_IS_INTEGER |
Indicates whether a variable is of the integer type. |
|
MDO_INT_ATTR_ROW_IIS |
Whether the lower or upper bound of constraint belong to IIS. |
|
MDO_INT_ATTR_COL_IIS |
Whether the lower or upper bound of variable belong to IIS. |
Note
If you have modified any attribute after solving a model, the solving result of the model before the modification cannot be obtained again, and you need to call the optimizer to solve the model again. 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.1.1. “ProbName”¶
This attribute is used to set and query the name of the current optimization model.
Group: Model
Type: String
Modifiable: Yes
Examples
C
Mdo_setStrAttr(model, "ProbName", "problem0"); Mdo_getStrAttr(model, "ProbName", maxlen, name);Note
The character array (see ‘’maxlen” in the sample code) should be long enough to avoid overflow.
C++
model.setStrAttr("ProbName", "problem0"); name = model.getStrAttr("ProbName");Python
model.set_str_attr("ProbName", "problem0") name = model.get_str_attr("ProbName")
8.7.1.2. “MinSense”¶
The minimization indicator. This attribute is used to set and query the meaning of an optimization target. “1” is the default value and indicates that the target function is a minimization target function. If you set this attribute to “0”, the target will be maximized.
Group: Model
Type: Integer
Modifiable: Yes
Default value: 1
Value |
Description |
---|---|
0 |
Maximizes the target. |
1 |
Minimizes the target. |
Examples
C
Mdo_setIntAttr(model, "MinSense", 1); Mdo_getIntAttr(model, "MinSense", &sense);C++
model.setIntAttr("MinSense", 1); sense = model.getIntAttr("MinSense");Python
model.set_int_attr("MinSense", 1) sense = model.get_int_attr("MinSense")
8.7.1.3. “ObjConst”¶
This attribute is used to set and query the constant offset of the target function.
Note
The target value will be deducted by the offset, regardless of whether the target function is minimized or maximized.
Group: Model
Type: Real
Modifiable: Yes
Examples
C
Mdo_setRealAttr(model, "ObjConst", 1.0); Mdo_getRealAttr(model, "ObjConst", &obj_offset);C++
model.setRealAttr("ObjConst", 1.0); obj_offset = model.getRealAttr("ObjConst");Python
model.set_real_attr("ObjConst", 1) obj_offset = model.get_real_attr("ObjConst")
8.7.1.4. “NumVars”¶
This attribute is used to query the total number of variables in the current optimization model.
Group: Model
Type: Integer
Modifiable: No
Examples
C
Mdo_getIntAttr(model, "NumVars", &num_vars);C++
num_vars = model.getIntAttr("NumVars");Python
num_vars = model.get_int_attr("NumVars")
8.7.1.5. “NumConss”¶
This attribute is used to query the total number of constraints in the current optimization model.
Group: Model
Type: Integer
Modifiable: No
Examples
C
Mdo_getIntAttr(model, "NumConss", &num_conss);C++
num_conss = model.getIntAttr("NumConss");Python
num_conss = model.get_int_attr("NumConss")
8.7.1.6. “NumEnts”¶
This attribute is used to query the total number of non-zero elements in the current optimization model.
Group: Model
Type: Integer
Modifiable: No
Examples
C
Mdo_getIntAttr(model, "NumEnts", &num_ents);C++
num_ents = model.getIntAttr("NumEnts");Python
num_ents = model.get_int_attr("NumEnts")
8.7.1.7. “LB”¶
This attribute is used to set and query the lower bound of a variable in the current optimization model.
Group: Model
Type: Real
Modifiable: Yes
Default value: 0.0
Note
Any value smaller than or equal to -1.E20 is considered to be negative infinite.
Examples
C
Mdo_setRealAttrIndex(model, "LB", 0, -10.0); Mdo_setRealAttrArray(model, "LB", 0, 4, lb_array); Mdo_getRealAttrIndex(model, "LB", 0, &lb); Mdo_getRealAttrArray(model, "LB", 0, 4, lb_array);C++
model.setRealAttrIndex("LB", 0, -10.0); model.setRealAttrArray("LB", 0, 4, lb_array); lb = model.getRealAttrIndex("LB", 0); lb_array = model.getRealAttrArray("LB", 0, 4); var.setRealAttr("LB", -10.0); lb = var.getRealAttr("LB");Python
model.set_real_attr_index("LB", 0, -10.0) model.set_real_attr_array("LB", 0, lb_array) lb = model.get_real_attr_index("LB", 0) lb_array = model.get_real_attr_array("LB", 0, 4) var.set_real_attr("LB", -10.0) lb = var.get_real_attr("LB")
8.7.1.8. “UB”¶
This attribute is used to set and query the upper bound of a variable in the current optimization model.
Group: Model
Type: Real
Modifiable: Yes
Default value: 0.0
Note
Any value greater than or equal to 1.E + 20 is considered to be positive infinite.
Examples
C
Mdo_setRealAttrIndex(model, "UB", 0, +10.0); Mdo_setRealAttrArray(model, "UB", 0, 4, ub_array); Mdo_getRealAttrIndex(model, "UB", 0, &ub); Mdo_getRealAttrArray(model, "UB", 0, 4, ub_array);C++
model.setRealAttrIndex("UB", 0, +10.0); model.setRealAttrArray("UB", 0, 4, ub_array); ub = model.getRealAttrIndex("UB", 0); ub_array = model.getRealAttrArray("UB", 0, 4); var.setRealAttr("UB", +10.0); ub = var.getRealAttr("UB");Python
model.set_real_attr_index("UB", 0, +10.0) model.set_real_attr_array("UB", 0, ub_array) ub = model.get_real_attr_index("UB", 0) ub_array = model.get_real_attr_array("UB", 0, 4) var.set_real_attr("UB", +10.0) ub = var.get_real_attr("UB")
8.7.1.9. “Obj”¶
This attribute is used to set and query the coefficient of variables in the target function in the current optimization model.
Group: Model
Type: Real
Modifiable: Yes
Default value: 0.0
Examples
C
Mdo_setRealAttrIndex(model, "Obj", 0, +10.0); Mdo_setRealAttrArray(model, "Obj", 0, 4, obj_array); Mdo_getRealAttrIndex(model, "Obj", 0, &obj); Mdo_getRealAttrArray(model, "Obj", 0, 4, obj_array);C++
model.setRealAttrIndex("Obj", 0, +10.0); model.setRealAttrArray("Obj", 0, 4, obj_array); obj = model.getRealAttrIndex("Obj", 0); obj_array = model.getRealAttrArray("Obj", 0, 4); var.setRealAttr("Obj", +10.0); obj = var.getRealAttr("Obj");Python
model.set_real_attr_index("Obj", 0, +10.0) model.set_real_attr_array("Obj", 0, obj_array) obj = model.get_real_attr_index("Obj", 0) obj_array = model.get_real_attr_array("Obj", 0, 4) var.set_real_attr("Obj", +10.0) obj = var.get_real_attr("Obj")
8.7.1.10. “LHS”¶
This attribute is used to set and query the upper bound (left-side value) of a constraint in the current optimization model.
Group: Model
Type: Real
Modifiable: Yes
Default value: 0.0
Note
Any value smaller than or equal to -1.E20 is considered to be negative infinite.
Examples
C
Mdo_setRealAttrIndex(model, "LHS", 0, -10.0); Mdo_setRealAttrArray(model, "LHS", 0, 4, lhs_array); Mdo_getRealAttrIndex(model, "LHS", 0, &lhs); Mdo_getRealAttrArray(model, "LHS", 0, 4, lhs_array);C++
model.setRealAttrIndex("LHS", 0, -10.0); model.setRealAttrArray("LHS", 0, 4, lhs_array); lhs = model.getRealAttrIndex("LHS", 0); lhs_array = model.getRealAttrArray("LHS", 0, 4); cons.setRealAttr("LHS", -10.0); lhs = cons.getRealAttr("LHS");Python
model.set_real_attr_index("LHS", 0, -10.0) model.set_real_attr_array("LHS", 0, lhs_array) lhs = model.get_real_attr_index("LHS", 0) lhs_array = model.get_real_attr_array("LHS", 0, 4) cons.set_real_attr("LHS", -10.0) lhs = cons.get_real_attr("LHS")
8.7.1.11. “RHS”¶
This attribute is used to set and query the upper bound (right-side value) of a constraint in the current optimization model.
Group: Model
Type: Real
Modifiable: Yes
Default value: 0.0
Note
Any value greater than or equal to 1.E + 20 is considered to be positive infinite.
Examples
C
Mdo_setRealAttrIndex(model, "RHS", 0, +10.0); Mdo_setRealAttrArray(model, "RHS", 0, 4, rhs_array); Mdo_getRealAttrIndex(model, "RHS", 0, &rhs); Mdo_getRealAttrArray(model, "RHS", 0, 4, rhs_array);C++
model.setRealAttrIndex("RHS", 0, +10.0); model.setRealAttrArray("RHS", 0, 4, rhs_array); rhs = model.getRealAttrIndex("RHS", 0); rhs_array = model.getRealAttrArray("RHS", 0, 4); cons.setRealAttr("RHS", +10.0); rhs = cons.getRealAttr("RHS");Python
model.set_real_attr_index("RHS", 0, +10.0) model.set_real_attr_array("RHS", 0, rhs_array) rhs = model.get_real_attr_index("RHS", 0) rhs_array = model.get_real_attr_array("RHS", 0, 4) cons.set_real_attr("RHS", +10.0) rhs = cons.get_real_attr("RHS")
8.7.1.12. “ColName”¶
This attribute is used to set and query the name of a variable in the current optimization model.
Group: Model
Type: String
Modifiable: Yes
Examples
C
Mdo_setStrAttrIndex(model, "ColName", 0, "x0"); Mdo_getStrAttrIndex(model, "ColName", 0, maxlen, name);C++
model.setStrAttrIndex("ColName", 0, "x0"); name = model.getStrAttrIndex("ColName", 0); x0.setStrAttr("ColName", "x0"); name = x0.getStrAttr("ColName");Python
model.set_str_attr_index("ColName", 0, "x0") name = model.get_str_attr_index("ColName", 0) x0.set_str_attr("ColName", "x0") name = x0.get_str_attr("ColName")
8.7.1.13. “RowName”¶
This attribute is used to set and query the name of a constraint in the current optimization model.
Group: Model
Type: String
Modifiable: Yes
Examples
C
Mdo_setStrAttrIndex(model, "RowName", 0, "c0"); Mdo_getStrAttrIndex(model, "RowName", 0, maxlen, name);C++
model.setStrAttrIndex("RowName", 0, "c0"); name = model.getStrAttrIndex("RowName", 0); c0.setStrAttr("RowName", "c0"); name = c0.getStrAttr("RowName");Python
model.set_str_attr_index("RowName", 0, "c0") name = model.get_str_attr_index("RowName", 0) c0.set_str_attr("RowName", "c0") name = c0.get_str_attr("RowName")
8.7.1.14. “IsInteger”¶
This attribute is used to set and query whether a variable is of the integer type.
Group: Common
Default value: 0
Value |
Description |
---|---|
0 |
A continuous variable. |
1 |
An integer variable. |
Examples
C
Mdo_setIntAttrIndex(model, "IsInteger", 0, 1); Mdo_setIntAttrArray(model, "IsInteger", 0, 4, is_integer_array); Mdo_getIntAttrIndex(model, "IsInteger", 0, &is_integer); Mdo_getIntAttrArray(model, "IsInteger", 0, 4, is_integer_array);C++
model.setIntAttrIndex("IsInteger", 0, 1); model.setIntAttrArray("IsInteger", 0, 4, is_integer_array); is_integer = model.getIntAttrIndex("IsInteger", 0); is_integer_array = model.getIntAttrArray("IsInteger", 0, 4); var.setIntAttr("IsInteger", 1); is_integer = var.getIntAttr("IsInteger");Python
model.set_int_attr_index("IsInteger", 0, 1) model.set_int_attr_array("IsInteger", 0, is_integer_array) is_integer = model.get_int_attr_index("IsInteger", 0) is_integer_array = model.get_int_attr_array("IsInteger", 0, 4) var.set_int_attr("IsInteger", 1) is_integer = var.get_int_attr("IsInteger")
8.7.1.15. “RowIIS”¶
Whether the lower or upper bound of constraint belong to IIS.
Group: Solution
Type: Integer
Modifiable: No
Examples
C
Mdo_getIntAttrIndex(model, "RowIIS", 0, &row_iis); Mdo_getIntAttrArray(model, "RowIIS", 0, 4, &row_iis_array);C++
row_iis = model.getIntAttrIndex("RowIIS", 0); row_iis_array = model.getIntAttrArray("RowIIS", 0, 4);Python
row_iis = model.get_int_attr_index("RowIIS", 0) row_iis_array = model.get_int_attr_array("RowIIS", 0, 4)
8.7.1.16. “ColIIS”¶
Whether the lower or upper bound of variable belong to IIS.
Group: Solution
Type: Integer
Modifiable: No
Examples
C
Mdo_getIntAttrIndex(model, "ColIIS", 0, &col_iis); Mdo_getIntAttrArray(model, "ColIIS", 0, 4, &col_iis_array);C++
col_iis = model.getIntAttrIndex("ColIIS", 0); col_iis_array = model.getIntAttrArray("ColIIS", 0, 4);Python
col_iis = model.get_int_attr_index("ColIIS", 0) col_iis_array = model.get_int_attr_array("ColIIS", 0, 4)