8.1. Attributes¶
The following example shows how to obtain the current attribute by five languages.
Python:
# Obtain model attributes model.status # case insensitive model.getAttr("Status") # Obtain variable attributes var.X # case insensitive var.get("X") # Obtain constraint attributes constr.lhs # case insensitive constr.get("LHS") # Obtain the PSD variable attribute px.psdx px.get("PsdX") # Obtain the PSD constraint attribute pconstr.psdcname # case insensitive pconstr.get("PsdCName")Java:
// Obtain model attributes // get int attr Status model.get(MDO.IntAttr.Status); // get double attr ObjVal model.get(MDO.DoubleAttr.ObjVal); // get string attr ModelName model.get(MDO.StringAttr.ModelName); // Obtain variable attributes // get int attr IsInteger var.get(MDO.IntAttr.IsInteger); // get double attr Obj var.get(MDO.DoubleAttr.Obj); // get string attr VarName var.get(MDO.StringAttr.VarName); // Obtain constraint attributes // get int attr RowBasis constr.get(MDO.IntAttr.RowBasis); // get double attr LHS constr.get(MDO.DoubleAttr.LHS); // get string attr ConstrName constr.get(MDO.StringAttr.ConstrName); // Obtain the PSD variable attribute // get int attr Dim px.get(MDO.IntAttr.Dim); // get matrix attr PsdObj px.get(MDO.MatAttr.PsdObj); // get string attr PsdVarName px.get(MDO.StringAttr.PsdVarName); // Obtain the PSD constraint attribute // get double attr PsdCLHS pconstr.get(MDO.DoubleAttr.PsdCLHS); // get string attr PsdCName pconstr.get(MDO.StringAttr.PsdCName);CPP:
// Obtain model attributes // get int attr Status model.get(MDO_IntAttr_Status); // get double attr ObjVal model.get(MDO_DoubleAttr_ObjVal); // get string attr ModelName model.get(MDO_StringAttr_ModelName); // Obtain variable attributes // get int attr IsInteger var.get(MDO_IntAttr_IsInteger); // get double attr Obj var.get(MDO_DoubleAttr_Obj); // get string attr VarName var.get(MDO_StringAttr_VarName); // Obtain constraint attributes // get int attr RowBasis constr.get(MDO_IntAttr_RowBasis); // get double attr LHS constr.get(MDO_DoubleAttr_LHS); // get string attr ConstrName constr.get(MDO_StringAttr_ConstrName); // Obtain the PSD variable attribute // get int attr Dim px.get(MDO_IntAttr_Dim); // get matrix attr PsdObj px.get(MDO_MatAttr_PsdObj); // get string attr PsdVarName px.get(MDO_StringAttr_PsdVarName); // Obtain the PSD constraint attribute // get double attr PsdCLHS pconstr.get(MDO_DoubleAttr_PsdCLHS); // get string attr PsdCName pconstr.get(MDO_StringAttr_PsdCName);C:
// Obtain model attributes // get int attr Status int status; MDOgetintattr(m, "Status", &status); // get double attr ObjVal double obj; MDOgetdblattr(m, "ObjVal", &obj) // get string attr ModelName char* nameget; MDOgetstrattr(m, "ModelName", &nameget); // Obtain variable attributes // i is the index of this variable in this model // get int attr IsInteger int isint; MDOgetintattrelement(m, "IsInteger", i, &isint); // get double attr X double x; MDOgetdblattrelement(m, "X", i, &x); // get string attr VarName char* varname; MDOgetstrattrelement(m, "VarName", i, &varname); // Obtain constraint attributes // i is the index of this constraint in this model // get int attr RowBasis int rowbasis; MDOgetintattrelement(m, "RowBasis", i, &rowbasis); // get double attr LHS double lhs; MDOgetdblattrelement(m, "LHS", i, &lhs); // get string attr ConstrName char* constrname; MDOgetstrattrelement(m, "ConstrName", i, &constrname); // Obtain the PSD variable attribute // i is the index of this PSD variable in this model // get int attr Dim int dim; MDOgetintattrelement(m, "Dim", i, &dim); // get matrix attr PsdObj int nummatnz, rows, cols, *ind; double *data; MDOgetmatattrelement(m, "PsdObj", i, &nummatnz, &rows, &cols, NULL, NULL); ind = (int *)malloc(sizeof(nummatnz)); data = (double *)malloc(sizeof(nummatnz)); MDOgetmatattrelement(m, "PsdObj", i, &nummatnz, &rows, &cols, ind, data); // get string attr PsdVarName char* psdvarname; MDOgetstrattrelement(m, "PsdVarName", i, &psdvarname); // Obtain the PSD constraint attribute // i is the index of this PSD variable in this model // get double attr PsdCLHS double psdclhs; MDOgetdblattrelement(m, "PsdCLHS", i, &psdclhs); // get string attr PsdCName char* psdcname; MDOgetstrattrelement(m, "PsdCName", i, &psdcname);C#
// Obtain model attributes // get int attr Status model.Get(MDO.IntAttr.Status); // get double attr ObjVal model.Get(MDO.DoubleAttr.ObjVal); // get string attr ModelName model.Get(MDO.StringAttr.ModelName); // Obtain variable attributes // get int attr IsInteger var.Get(MDO.IntAttr.IsInteger); // get double attr Obj var.Get(MDO.DoubleAttr.Obj); // get string attr VarName var.Get(MDO.StringAttr.VarName); // Obtain constraint attributes // get int attr RowBasis constr.Get(MDO.IntAttr.RowBasis); // get double attr LHS constr.Get(MDO.DoubleAttr.LHS); // get string attr ConstrName constr.Get(MDO.StringAttr.ConstrName); // Obtain the PSD variable attribute // get int attr Dim px.Get(MDO.IntAttr.Dim); // get matrix attr PsdObj px.Get(MDO.MatAttr.PsdObj); // get string attr PsdVarName px.Get(MDO.StringAttr.PsdVarName); // Obtain the PSD constraint attribute // get double attr PsdCLHS pconstr.Get(MDO.DoubleAttr.PsdCLHS); // get string attr PsdCName pconstr.Get(MDO.StringAttr.PsdCName);The following examples shows how to modify the current attribute by five languages.
Python:
# Modify model attributes model.modelname = "DietProblem" # case insensitive model.setAttr("ModelName", "DietProblem") # Modify variable attributes x.lb = -10 # case insensitive x.setAttr("LB", -10) # Modify constraint attributes constr.constrname = "c1" # case insensitive constr.setAttr("ConstrName", "c1") # Modify the attributes of the PSD variable. psdx.psdvarname = "psd1" # case insensitive psdx.setAttr("PsdVarName", "psd1") # Modify the PSD constraint properties psdc.psdcname = "psdconstr1" # case insensitive psdc.setAttr("PsdCName", "psdconstr1")Java:
// Modify model attributes // set int attr ModelSense model.set(MDO.IntAttr.ModelSense, MDO.MINIMIZE); // set double attr ObjCon model.set(MDO.DoubleAttr.ObjCon, 5.0); // set string attr ModelName model.set(MDO.StringAttr.ModelName, "diet"); // Modify variable attributes // set int attr ColBasis var.set(MDO.IntAttr.ColBasis, 1); // set double attr Obj var.set(MDO.DoubleAttr.Obj, 2.0); // set char attr VType var.set(MDO.CharAttr.VType, MDO.CONTINUOUS); // set string attr VarName var.set(MDO.StringAttr.VarName, "var1"); // Modify constraint attributes // set int attr RowBasis constr.set(MDO.IntAttr.RowBasis, 3); // set double attr LHS constr.set(MDO.DoubleAttr.LHS, 1.88); // set string attr ConstrName constr.set(MDO.StringAttr.ConstrName, "c1"); // Modify the attributes of the PSD variable. // set matirx attr PsdObj MDOMatrix c = new MDOMatrix(0, 0, 0, 0,null, null); psdx.set(MDO.MatAttr.PsdObj, c.full(4, 4, 12)); // set string attr PsdVarName psdx.set(MDO.StringAttr.PsdVarName, "psd1"); // Modify the PSD constraint properties // set double attr PsdCLHS pconstr.set(MDO.DoubleAttr.PsdCLHS, 1.88); // set string attr PsdCName pconstr.set(MDO.StringAttr.PsdCName, "pc1");CPP:
// Modify model attributes // set int attr ModelSense model.set(MDO_IntAttr_ModelSense, MDO_MAXIMIZE); // set double attr ObjVal model.set(MDO_DoubleAttr_ObjVal, 5.0); // set string attr ModelName model.set(MDO_StringAttr_ModelName, "diet"); // Modify variable attributes // set int attr ColBasis var.set(MDO_IntAttr_ColBasis, 1); // set double attr Obj var.set(MDO_DoubleAttr_Obj, 2.0); // set char attr VType var.set(MDO_CharAttr_VType, MDO_CONTINUOUS); // set string attr VarName var.set(MDO_StringAttr_VarName, "var1"); // Modify constraint attributes // set int attr RowBasis constr.set(MDO_IntAttr_RowBasis, 3); // set double attr LHS constr.set(MDO_DoubleAttr_LHS, 1.88); // set string attr ConstrName constr.set(MDO_StringAttr_ConstrName, "c1"); // Modify the attributes of the PSD variable. // set matirx attr PsdObj MDOMatrix c = new MDOMatrix(0, 0, 0, 0,null, null); psdx.set(MDO_MatAttr_PsdObj, c.full(4, 4, 12)); // set string attr PsdVarName psdx.set(MDO_StringAttr_PsdVarName, "psd1"); // Modify the PSD constraint properties // set double attr PsdCLHS pconstr.set(MDO_DoubleAttr_PsdCLHS, 1.88); // set string attr PsdCName pconstr.set(MDO_StringAttr_PsdCName, "pc1");C:
// Modify model attributes // set int attr ModelSense MDOsetintattr(m, "ModelSense", MDO_MINIMIZE); // set double attr ObjCon MDOsetdblattr(m, "ObjCon", 5.0); // set string attr ModelName char *mname[20]; sprintf(mname, "diet_problem"); MDOsetstrattr(m, "ModelName", mname); // Modify variable attributes // i is the index of this variable in this model // set int attr ColBasis MDOsetintattrelement(m, "ColBasis", i, val); // set double attr Obj MDOsetdblattrelement(m, "Obj", i, 2.0); // set char attr VType MDOsetcharattrelement(m, "VType", i, 'c'); // set string attr VarName char *varname[20]; sprintf(varname, "var1"); MDOsetstrattrelement(m, "VarName", i, varname); // Modify constraint attributes // i is the index of this constraint in this model // set int attr RowBasis MDOsetintattrelement(m, "ColBRowBasissis", i, 3); // set double attr LHS MDOsetdblattrelement(m, "LHS", i, 2.0); // set string attr ConstrName char *cname[20]; sprintf(cname, "constr1"); MDOsetstrattrelement(m, "ConstrName", i, cname); // Modify the attributes of the PSD variable. // i is the index of this PSD variable in this model // set matirx attr PsdObj int nummatnz, rows, cols, *ind; double *data; // allocate memory for these variables and assign values MDOsetmatattrelement(m, "PsdObj", i, nummatnz, rows, cols, ind, data); // set string attr PsdVarName char *pxname[20]; sprintf(pxname, "psdv1"); MDOsetstrattrelement(m, "PsdVarName", i, pxname); // Modify the PSD constraint properties // i is the index of this PSD constraint in this model // set double attr PsdCLHS MDOsetdblattrelement(m, "MDO_DoubleAttr_PsdCLHS", i, 2.0); // set string attr PsdCName char *pcname[20]; sprintf(pcname, "psdc1"); MDOsetstrattrelement(m, "PsdCName", i, pcname);C#
// Modify model attributes // set int attr ModelSense model.Set(MDO.IntAttr.ModelSense, MDO.MINIMIZE); // set double attr ObjCon model.Set(MDO.DoubleAttr.ObjCon, 5.0); // set string attr ModelName model.Set(MDO.StringAttr.ModelName, "diet"); // Modify variable attributes // set int attr ColBasis var.Set(MDO.IntAttr.ColBasis, 1); // set double attr Obj var.Set(MDO.DoubleAttr.Obj, 2.0); // set char attr VType var.Set(MDO.CharAttr.VType, MDO.CONTINUOUS); // set string attr VarName var.Set(MDO.StringAttr.VarName, "var1"); // Modify constraint attributes // set int attr RowBasis constr.Set(MDO.IntAttr.RowBasis, 3); // set double attr LHS constr.Set(MDO.DoubleAttr.LHS, 1.88); // set string attr ConstrName constr.Set(MDO.StringAttr.ConstrName, "c1"); // Modify the attributes of the PSD variable. // set matirx attr PsdObj psdx.Set(MDO.MatAttr.PsdObj, MDOMatrix.Identity(4)); // set string attr PsdVarName psdx.Set(MDO.StringAttr.PsdVarName, "psd1"); // Modify the PSD constraint properties // set double attr PsdCLHS pconstr.Set(MDO.DoubleAttr.PsdCLHS, 1.88); // set string attr PsdCName pconstr.Set(MDO.StringAttr.PsdCName, "pc1");
8.1.1. Model attributes¶
double
The objective value of dual solution
int
If the problem has dual ray
int
If the problem has primal ray
int
If the problem has solution
int
The total number of iterations after a interior point method completed
double
The absolute gap for a mip solution
double
The relative gap for a mip solution
int
If the objective function is min sense
string
Alias for ProbName
int
The objective function sense, 1 for min and -1 for max
int
The total number of constraints
int
Alias for NumConss
int
The total number of constraint matrix non-zeros
int
The total number of general constraints
int
Alias for NumEnts
int
The total number of psd constraints
int
The total number of psd variables
int
The total number of quadratic constraints
int
The total number of Special Ordered Set (SOS) constraints in the model
int
The total number of variables
double
Alias for ObjConst
double
The constant component of objective function
double
Alias for PrimalObjVal
double
Presolver execution time in seconds
double
The objective value of primal solution
string
The problem name
int
The total number of iterations after a simplex method completed
int
Total number of suboptimal solutions found
double
Total execution time in seconds
double
Solver execution time in seconds
int
The optimization status after model optimized
8.1.1.1. DualObjVal¶
The objective value of dual solution
Type: double
Settable: No
8.1.1.2. HasDualRay¶
If the problem has dual ray
Type: int
Settable: No
0
Unavailable
1
Available
8.1.1.3. HasPrimalRay¶
If the problem has primal ray
Type: int
Settable: No
0
Unavailable
1
Available
8.1.1.4. HasSolution¶
If the problem has solution
Type: int
Settable: No
0
Unavailable
1
Available
8.1.1.5. IPM/NumIters¶
The total number of iterations after a interior point method completed
Type: int
Settable: No
8.1.1.6. MIP/GapAbs¶
The absolute gap for a mip solution. If user want to set max tolerable gap before optimization, see parameter MIP/GapAbs
Type: double
Settable: No
8.1.1.7. MIP/GapRel¶
The relative gap for a mip solution. If user want to set max tolerable gap before optimization, see parameter MIP/GapRel
Type: double
Settable: No
8.1.1.8. MinSense¶
If the objective function is min sense
Type: int
Settable: Yes
0
Maximizes the target.
1
Minimizes the target.
8.1.1.9. ModelName¶
Alias for ProbName. The problem name
Type: string
Settable: Yes
8.1.1.10. ModelSense¶
The objective function sense, 1 for min and -1 for max
Type: int
Settable: Yes
1
Minimization
-1
Maximization
8.1.1.11. NumConss¶
The total number of constraints
Type: int
Settable: No
8.1.1.12. NumConstrs¶
Alias for NumConss. The total number of constraints
Type: int
Settable: No
8.1.1.13. NumEnts¶
The total number of constraint matrix non-zeros
Type: int
Settable: No
8.1.1.14. NumGenConstrs¶
The total number of general constraints.
Type: int
Settable: No
8.1.1.15. NumNZs¶
Alias for NumEnts. The total number of constraint matrix non-zeros
Type: int
Settable: No
8.1.1.16. NumPsdConstrs¶
The total number of psd constraints
Type: int
Settable: No
8.1.1.17. NumPsdVars¶
The total number of psd variables
Type: int
Settable: No
8.1.1.18. NumQConstrs¶
The total number of quadratic constraints
Type: int
Settable: No
8.1.1.19. NumSOS¶
The total number of Special Ordered Set (SOS) constraints in the model
Type: int
Settable: No
8.1.1.20. NumVars¶
The total number of variables
Type: int
Settable: No
8.1.1.21. ObjCon¶
Alias for ObjConst. The constant component of objective function
Type: double
Settable: Yes
8.1.1.22. ObjConst¶
The constant component of objective function
Type: double
Settable: Yes
8.1.1.23. ObjVal¶
Alias for PrimalObjVal. The objective value of primal solution
Type: double
Settable: No
8.1.1.24. PresolverTime¶
Presolver execution time in seconds
Type: double
Settable: No
8.1.1.25. PrimalObjVal¶
The objective value of primal solution
Type: double
Settable: No
8.1.1.26. ProbName¶
The problem name
Type: string
Settable: Yes
8.1.1.27. SPX/NumIters¶
The total number of iterations after a simplex method completed
Type: int
Settable: No
8.1.1.28. SolCount¶
Total number of suboptimal solutions found.
Type: int
Settable: No
8.1.1.29. SolutionTime¶
Total execution time in seconds
Type: double
Settable: No
8.1.1.30. SolverTime¶
Solver execution time in seconds
Type: double
Settable: No
8.1.1.31. Status¶
The optimization status after model optimized
Type: int
Settable: No
0
UNKNOWN: Model status is not available.
1
OPTIMAL: Model was proven to be primal/dual feasible, and an optimal solution is available.
2
INFEASIBLE: Model was proven to be primal infeasible.
3
UNBOUNDED: Model was proven to be primal unbounded.
4
INF_OR_UBD: Model was proven to be either primal infeasible or primal unbounded.
5
SUB_OPTIMAL: A sub-optimal solution is available.
8.1.2. Variable attributes¶
int
The basis of a column
string
The variable name
int
Alias for IISVar, to test if the upper and (or) lower bound(s) of this variable belong to IIS
int
If the upper and (or) lower bound(s) of this variable belong to IIS
int
If a variable is integral type
double
The lower bound of a variable
double
The objective coefficient of a variable
double
The solution of primal problem
double
Alias for ReducedCost
double
The reduced cost
double
The current MIP start vector
double
The upper bound of a variable
char
The variable type
string
Alias for ColName, The variable name
double
Alias for PrimalSoln
double
The suboptimal solution specified by parameter MIP/SolutionNumber
8.1.2.1. ColBasis¶
The basis of a column
Type: int
Settable: Yes
0
isFree
1
basic
2
atUpperBound
3
atLowerBound
4
superBasic
5
isFixed
8.1.2.2. ColName¶
The variable name
Type: string
Settable: Yes
8.1.2.3. IISCol¶
Alias for IISVar, to test if the upper and (or) lower bound(s) of this variable belong to IIS
Type: int
Settable: No
8.1.2.4. IISVar¶
If the upper and (or) lower bound(s) of this variable belong to IIS
Type: int
Settable: No
2
Upper bound of variable belongs to IIS
3
Lower bound of variable belongs to IIS
5
Its a fixed variable (LB = UB), its fixed value belongs to IIS
6
No bounds of variable belongs to IIS
8.1.2.5. IsInteger¶
If a variable is integral type
Type: int
Settable: Yes
0
A continuous variable.
1
An integer variable.
8.1.2.6. LB¶
The lower bound of a variable
Type: double
Settable: Yes
8.1.2.7. Obj¶
The objective coefficient of a variable
Type: double
Settable: Yes
8.1.2.8. PrimalSoln¶
The solution of primal problem
Type: double
Settable: No
8.1.2.9. RC¶
Alias for ReducedCost. The reduced cost
Type: double
Settable: No
8.1.2.10. ReducedCost¶
The reduced cost
Type: double
Settable: No
8.1.2.11. Start¶
The current MIP start vector
Type: double
Settable: Yes
8.1.2.12. UB¶
The upper bound of a variable
Type: double
Settable: Yes
8.1.2.13. VType¶
The variable type
Type: char
Settable: Yes
MDO_CONTINUOUS(‘C’)
continuous variable
MDO_BINARY(‘B’)
binary variable
MDO_INTEGER(‘I’)
integral variable
MDO_SEMICONT(‘S’)
semi-continuous variable
MDO_SEMIINT(‘N’)
semi-integral variable
8.1.2.14. VarName¶
Alias for ColName, The variable name
Type: string
Settable: Yes
8.1.2.15. X¶
Alias for PrimalSoln. The solution of primal problem
Type: double
Settable: No
8.1.2.16. Xn¶
The suboptimal solution specified by parameter MIP/SolutionNumber .
Type: double
Settable: No
8.1.3. Constraint attributes¶
double
The primal activity
string
Alias for RowName
double
The solution of dual problem
int
If the left-hand-side value and (or) right-hand-side value of this constraint belong to IIS
int
Alias for IISConstr, to test if the left-hand-side value and (or) right-hand-side value of this constraint belong to IIS
double
The left-hand-side value of a constraint
double
The right-hand-side value of a constraint
int
The basis of a row
string
The constraint name
8.1.3.1. Activity¶
The primal activity
Type: double
Settable: No
8.1.3.2. ConstrName¶
Alias for RowName. The constraint name
Type: string
Settable: Yes
8.1.3.3. DualSoln¶
The solution of dual problem
Type: double
Settable: No
8.1.3.4. IISConstr¶
If the left-hand-side value and (or) right-hand-side value of this constraint belong to IIS
Type: int
Settable: No
2
RHS of constraint belongs to IIS
3
LHS of constraint belongs to IIS
5
Its an equivalence constraint(LHS = RHS), its fixed value belongs to IIS
6
Neither LHS nor RHS of constraint belongs to IIS
8.1.3.5. IISRow¶
Alias for IISConstr, to test if the left-hand-side value and (or) right-hand-side value of this constraint belong to IIS
Type: int
Settable: No
8.1.3.6. LHS¶
The left-hand-side value of a constraint
Type: double
Settable: Yes
8.1.3.7. RHS¶
The right-hand-side value of a constraint
Type: double
Settable: Yes
8.1.3.8. RowBasis¶
The basis of a row
Type: int
Settable: Yes
0
isFree
1
basic
2
atUpperBound
3
atLowerBound
4
superBasic
5
isFixed
8.1.3.9. RowName¶
The constraint name
Type: string
Settable: Yes
8.1.4. Quadratic constraint attributes¶
8.1.4.1. QCLHS¶
The left-hand-side value of a quadratic constraint
Type: double
Settable: Yes
8.1.4.2. QCName¶
The quadratic constraint name
Type: string
Settable: Yes
8.1.4.3. QCRHS¶
The right-hand-side value of a quadratic constraint
Type: double
Settable: Yes
8.1.5. General constraint attributes¶
string
The name of this general constraint
int
The type of this general constraint
8.1.5.1. GenConstrName¶
The name of this general constraint
Type: string
Settable: Yes
8.1.5.2. GenConstrType¶
The type of this general constraint
Type: int
Settable: No
6
Indicator constraint
8.1.6. PSD variable attributes¶
int
The dimension of a psd variable
matrix
The objective coefficient of a psd variable
string
The psd variable name
matrix
The solution of psd variable in primal problem
8.1.6.1. Dim¶
The dimension of a psd variable
Type: int
Settable: No
8.1.6.2. PsdObj¶
The objective coefficient of a psd variable
Type: matrix
Settable: Yes
8.1.6.3. PsdVarName¶
The psd variable name
Type: string
Settable: Yes
8.1.6.4. PsdX¶
The solution of psd variable in primal problem
Type: matrix
Settable: No