8.1. Attributes

The following example shows how to obtain the current attribute by four 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);

The following examples shows how to modify the current attribute by four 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);

8.1.1. Model attributes

DualObjVal

double

The objective value of dual solution

HasDualRay

int

If the problem has dual ray

HasPrimalRay

int

If the problem has primal ray

HasSolution

int

If the problem has solution

IPM/NumIters

int

The total number of iterations after a interior point method completed

MIP/GapAbs

double

The absolute gap for a mip solution

MIP/GapRel

double

The relative gap for a mip solution

MinSense

int

If the objective function is min sense

ModelName

string

Alias for ProbName

ModelSense

int

The objective function sense, 1 for min and -1 for max

NumConss

int

The total number of constraints

NumConstrs

int

Alias for NumConss

NumEnts

int

The total number of constraint matrix non-zeros

NumGenConstrs

int

The total number of general constraints

NumNZs

int

Alias for NumEnts

NumPsdConstrs

int

The total number of psd constraints

NumPsdVars

int

The total number of psd variables

NumSOS

int

The total number of Special Ordered Set (SOS) constraints in the model

NumVars

int

The total number of variables

ObjCon

double

Alias for ObjConst

ObjConst

double

The constant component of objective function

ObjVal

double

Alias for PrimalObjVal

PresolverTime

double

Presolver execution time in seconds

PrimalObjVal

double

The objective value of primal solution

ProbName

string

The problem name

SPX/NumIters

int

The total number of iterations after a simplex method completed

SolutionTime

double

Total execution time in seconds

SolverTime

double

Solver execution time in seconds

Status

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

  • Type: double

  • Settable: No

8.1.1.7. MIP/GapRel

The relative gap for a mip solution

  • 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. NumSOS

The total number of Special Ordered Set (SOS) constraints in the model

  • Type: int

  • Settable: No

8.1.1.19. NumVars

The total number of variables

  • Type: int

  • Settable: No

8.1.1.20. ObjCon

Alias for ObjConst. The constant component of objective function

  • Type: double

  • Settable: Yes

8.1.1.21. ObjConst

The constant component of objective function

  • Type: double

  • Settable: Yes

8.1.1.22. ObjVal

Alias for PrimalObjVal. The objective value of primal solution

  • Type: double

  • Settable: No

8.1.1.23. PresolverTime

Presolver execution time in seconds

  • Type: double

  • Settable: No

8.1.1.24. PrimalObjVal

The objective value of primal solution

  • Type: double

  • Settable: No

8.1.1.25. ProbName

The problem name

  • Type: string

  • Settable: Yes

8.1.1.26. SPX/NumIters

The total number of iterations after a simplex method completed

  • Type: int

  • Settable: No

8.1.1.27. SolutionTime

Total execution time in seconds

  • Type: double

  • Settable: No

8.1.1.28. SolverTime

Solver execution time in seconds

  • Type: double

  • Settable: No

8.1.1.29. Status

The optimization status after model optimized

  • Type: int

  • Settable: No

8.1.2. Variable attributes

ColBasis

int

The basis of a column

ColName

string

The variable name

IISCol

int

Alias for IISVar, to test if the upper and (or) lower bound(s) of this variable belong to IIS

IISVar

int

If the upper and (or) lower bound(s) of this variable belong to IIS

IsInteger

int

If a variable is integral type

LB

double

The lower bound of a variable

Obj

double

The objective coefficient of a variable

PrimalSoln

double

The solution of primal problem

RC

double

Alias for ReducedCost

ReducedCost

double

The reduced cost

Start

double

The current MIP start vector

UB

double

The upper bound of a variable

VType

char

The variable type

VarName

string

Alias for ColName, The variable name

X

double

Alias for PrimalSoln

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

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.3. Constraint attributes

Activity

double

The primal activity

ConstrName

string

Alias for RowName

DualSoln

double

The solution of dual problem

IISConstr

int

If the left-hand-side value and (or) right-hand-side value of this constraint belong to IIS

IISRow

int

Alias for IISConstr, to test if the left-hand-side value and (or) right-hand-side value of this constraint belong to IIS

LHS

double

The left-hand-side value of a constraint

RHS

double

The right-hand-side value of a constraint

RowBasis

int

The basis of a row

RowName

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. General constraint attributes

GenConstrName

string

The name of this general constraint

GenConstrType

int

The type of this general constraint

8.1.4.1. GenConstrName

The name of this general constraint

  • Type: string

  • Settable: Yes

8.1.4.2. GenConstrType

The type of this general constraint

  • Type: int

  • Settable: No

6

Indicator constraint

8.1.5. PSD variable attributes

Dim

int

The dimension of a psd variable

PsdObj

matrix

The objective coefficient of a psd variable

PsdVarName

string

The psd variable name

PsdX

matrix

The solution of psd variable in primal problem

8.1.5.1. Dim

The dimension of a psd variable

  • Type: int

  • Settable: No

8.1.5.2. PsdObj

The objective coefficient of a psd variable

  • Type: matrix

  • Settable: Yes

8.1.5.3. PsdVarName

The psd variable name

  • Type: string

  • Settable: Yes

8.1.5.4. PsdX

The solution of psd variable in primal problem

  • Type: matrix

  • Settable: No

8.1.6. PSD constraint attributes

PsdCLHS

double

psd contraint left-hand-side value

PsdCName

string

The psd constraint name

PsdCRHS

double

psd contraint right-hand-side value

8.1.6.1. PsdCLHS

psd contraint left-hand-side value

  • Type: double

  • Settable: Yes

8.1.6.2. PsdCName

The psd constraint name

  • Type: string

  • Settable: Yes

8.1.6.3. PsdCRHS

psd contraint right-hand-side value

  • Type: double

  • Settable: Yes