8.4.15. MDOModel

class MDOModel

Represent a model in MindOpt application

Methods

MDOModel

Construct a model with its associated environment

MDOModel

Construct a model with its associated environment

MDOModel

Read a model from file with its associated environment

MDOModel

Read a model from file with its associated environment

MDOModel

Copy a model from another exist model

addConstr

Add a new linear constraint to this model

addConstr

Add a new linear constraint to this model

addConstr

Add a new linear constraint to this model

addConstr

Add a new linear constraint to this model

addConstr

Add a new linear constraint to this model

addConstr

Add a new constraint to this model, constraint type depends on the value of temp constraint

addConstrs

Add an amount of constraints to this model

addConstrs

Add an amount of constraints to this model

addGenConstrIndicator

Add a new indicator constraint to this model

addGenConstrIndicator

Add a new indicator constraint to this model

addPsdConstr

Add a new PSD constraint to this model

addPsdVar

Add a new PSD variables by indicating its dimension and name

addPsdVar

Add a new PSD variables by indicating its objective coefficient and name

addRange

Add a new range constraint to this model

addRangePsdConstr

Add a new range PSD constraint to this model

addRanges

Add an amount of range constraints to this model

addSOS

Add an SOS constraint to the model

addVar

Add a variable to this model by indicate its lower bound, upper bound, objective coefficient, type and name

addVar

Add a variable to this model and associate it to exist constraints

addVar

Add a variable to this model and associate it to exist constraints by indicating a constraint matrix column

addVars

Add cnt typed variables to this model

addVars

Add an amount of variables

addVars

Add an amount of variables

chgCoeff

Change the constraint coefficient in constraint matrix

chgCoeffs

Change constraint coefficients in constraint matrix

computeIIS

Compute an IIS(Irreducible Inconsistent Subsystem)

get

Retrieve value of an int parameter by its name

get

Retrieve value of a double parameter by its name

get

Retrieve value of a string parameter by its name

get

Retrieve the value of an int attribute

get

Retrieve the value of a double attribute

get

Retrieve the value of a string attribute

get

Retrieve values of named attributes associated to variables

get

Retrieve values of named attributes associated to variables

get

Retrieve values of named attributes associated to variables

get

Retrieve values of named attributes associated to variables

get

Retrieve values of named attributes associated to constraints

get

Retrieve values of named attributes associated to constraints

get

Retrieve values of named attributes associated to constraints

get

Retrieve values of named attributes associated to constraints

get

Retrieve values of named attributes associated to PSD variables

get

Retrieve values of named attributes associated to PSD variables

get

Retrieve values of named attributes associated to PSD variables

get

Retrieve values of named attributes associated to PSD constraints

get

Retrieve values of named attributes associated to PSD constraints

get

Retrieve values of named attributes associated to general constraint

get

Retrieve values of named attributes associated to general constraints

getCoeff

Retrieve a coefficient value from constraint matrix

getCol

Retrieve a column from constraint matrix

getConstr

Retrieve the ith constraint in this model

getConstrByName

Retrieve a constraint by its name

getConstrs

Retrieve all constraints in this model

getEnv

Retrieve the environment associated to this model

getGenConstrIndicator

Retrieve indicator constraint in this model

getGenConstrs

Retrieve all general constraints in the current model

getObjective

Retrieve the objective function of this model

getPsdConstr

Retrieve the ith PSD constraint in this model

getPsdConstrs

Retrieve all PSD constraints in this model

getPsdVar

Retrieve the ith PSD variable

getPsdVars

Retrieve all PSD variables in this model

getRow

Retrieve a row from constraint matrix

getSOS

Retrieves the variables and coefficients contained in the SOS constraint

getSOSs

Retrieve all SOS constraints in the current model

getVar

Retrieve the ith variable in this model

getVarByName

Retrieve a variable by its name

getVars

Retrieve all variables in this model

optimize

Start to optimize the model

read

Read data into this model from a file

remove

Remove variable from this model

remove

Remove constraint from this model

remove

Remove SOS constraints from this model

remove

Remove general constraints from this model

reset

Reset the model to an unsolved state, discarding any previously computed solution

set

Set the value of an int parameter

set

Set the value of a double parameter

set

Set the value of a string parameter

set

Set the value of a parameter

set

Set the value of an int attribute

set

Set the value of a double attribute

set

Set the value of a string attribute

set

Set the values of named attributes associated to variables

set

Set the values of named attributes associated to variables

set

Set the values of named attributes associated to variables

set

Set the values of named attributes associated to variables

set

Set the values of named attributes associated to constraints

set

Set the values of named attributes associated to constraints

set

Set the values of named attributes associated to constraints

set

Set the values of named attributes associated to constraints

set

Set the values of named attributes associated to PSD variables

set

Set the values of named attributes associated to PSD variables

set

Set the values of named attributes associated to PSD variables

set

Set the values of named attributes associated to PSD constraints

set

Set the values of named attributes associated to PSD constraints

set

Set the values of named attributes associated to general constraints

setCallback

Set up a user defined callback class object

setObjective

Set the objective function

setObjective

Set the objective function

setObjective

Set the objective function

write

Write model data to a file

MDOModel(const MDOEnv *env)

Construct a model with its associated environment.

Parameters

const MDOEnv* env – The associated environment

MDOModel(const MDOEnv &env)

Construct a model with its associated environment.

Parameters

const MDOEnv& env – The associated environment

MDOModel(const MDOEnv *env, const std::string &filename)

Read a model from file with its associated environment.

Parameters
  • const MDOEnv* env – The associated environment

  • const std::string& filename – The file name to be read model from. File format and compression type should be encoded in filename as a suffix. Valid file format include .lp, .mps, .qps, .dat-s, supported compression types include .gz and .bz2.

MDOModel(const MDOEnv &env, const std::string &filename)

Read a model from file with its associated environment.

Parameters
  • const MDOEnv& env – The associated environment

  • const std::string& filename – The file name to be read model from. File format and compression type should be encoded in filename as a suffix. Valid file format include .lp, .mps, .qps, .dat-s, supported compression types include .gz and .bz2.

MDOModel(const MDOModel &xmodel)

Copy a model from another exist model.

Parameters

const MDOModel& xmodel – The exist model to be copied from.

MDOConstr addConstr(const MDOLinExpr &expr1, char sense, const MDOLinExpr &expr2, const std::string &name = "")

Add a new linear constraint to this model.

Parameters
  • const MDOLinExpr& expr1 – The left-hand-side linear expression.

  • char sense

    The inequality sign. Supported senses include:

    • MDO_EQUAL

    • MDO_LESS_EQUAL

    • MDO_GREATER_EQUAL

  • const MDOLinExpr& expr2 – The right-hand-side linear expression.

  • const std::string& name="" – The name of new constraint, an empty string is allowed, in which case a system generated name will be given.

Returns

The newly added constraint.

MDOConstr addConstr(const MDOLinExpr &expr1, char sense, MDOVar v, const std::string &name = "")

Add a new linear constraint to this model.

Parameters
  • const MDOLinExpr& expr1 – The left-hand-side linear expression.

  • char sense

    The inequality sign. Supported senses include:

    • MDO_EQUAL

    • MDO_LESS_EQUAL

    • MDO_GREATER_EQUAL

  • MDOVar v – The right-hand-side variable

  • const std::string& name="" – The name of new constraint, an empty string is allowed, in which case a system generated name will be given.

Returns

The newly added constraint.

MDOConstr addConstr(MDOVar v1, char sense, MDOVar v2, const std::string &name = "")

Add a new linear constraint to this model.

Parameters
  • MDOVar v1 – The left-hand-side variable.

  • char sense

    The inequality sign. Supported senses include:

    • MDO_EQUAL

    • MDO_LESS_EQUAL

    • MDO_GREATER_EQUAL

  • MDOVar v2 – The right-hand-side variable

  • const std::string& name="" – The name of new constraint, an empty string is allowed, in which case a system generated name will be given.

Returns

The newly added constraint.

MDOConstr addConstr(MDOVar v, char sense, double rhs, const std::string &name = "")

Add a new linear constraint to this model.

Parameters
  • MDOVar v – The left-hand-side variable.

  • char sense

    The inequality sign. Supported senses include:

    • MDO_EQUAL

    • MDO_LESS_EQUAL

    • MDO_GREATER_EQUAL

  • double rhs – The right-hand-side value

  • const std::string& name="" – The name of new constraint, an empty string is allowed, in which case a system generated name will be given.

Returns

The newly added constraint.

MDOConstr addConstr(const MDOLinExpr &expr, char sense, double rhs, const std::string &name = "")

Add a new linear constraint to this model.

Parameters
  • const MDOLinExpr& expr – The left-hand-side linear expression.

  • char sense

    The inequality sign. Supported senses include:

    • MDO_EQUAL

    • MDO_LESS_EQUAL

    • MDO_GREATER_EQUAL

  • double rhs – The right-hand-side value.

  • const std::string& name="" – The name of new constraint, an empty string is allowed, in which case a system generated name will be given.

Returns

The newly added constraint.

MDOConstr addConstr(const MDOTempConstr &tc, const std::string &name = "")

Add a new constraint to this model, constraint type depends on the value of temp constraint.

Parameters
  • const MDOTempConstr& tc – The temporary constraint to be added.

  • const std::string& name="" – The name of new constraint, an empty string is allowed, in which case a system generated name will be given.

Returns

The newly added constraint.

MDOConstr *addConstrs(int cnt)

Add an amount of constraints to this model.

Parameters

int cnt – The number of constraints to be added.

Returns

The newly added constraints.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

MDOConstr *addConstrs(const MDOLinExpr *expr, const char *sense, const double *rhs, const std::string &name = "", int len)

Add an amount of constraints to this model.

Parameters
  • const MDOLinExpr* expr – The linear expressions of new constraints. 0 will be used as a left-hand-side value.

  • const char* sense

    The inequality sign of new constraints. ‘MDO_LESS_EQUAL’s will be used if NULL presents. Supported senses include:

    • MDO_EQUAL

    • MDO_LESS_EQUAL

    • MDO_GREATER_EQUAL

  • const double* rhs – The right-hand-side value of new constraints. MDO_INFINITY s will be used if NULL presents.

  • const std::string& name="" – The names of new constraints, System generated names will be given if NULL presents.

  • int len – The number of constraints to be added.

Returns

The newly added constraints.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

MDOGenConstr addGenConstrIndicator(MDOVar binvar, int binval, const MDOLinExpr &expr, char sense, double rhs, const std::string &name = "")

Add a new indicator constraint to this model.

Parameters
  • MDOVar binvar – The binary variable of this indicator constraint.

  • int binval – The binary value when indicator constraint take effect.

  • const MDOLinExpr& expr – The linear expression of new indicator constraint.

  • char sense – The constraint sense of new indicator constraint.

  • double rhs – The right-hand-side value of new indicator constraint.

  • const std::string& name="" – The name of new indicator constraint.

Returns

The newly added general constraint.

MDOGenConstr addGenConstrIndicator(MDOVar binvar, int binval, const MDOTempConstr &expr, const std::string &name = "")

Add a new indicator constraint to this model.

Parameters
  • MDOVar binvar – The binary variable of this indicator constraint.

  • int binval – The binary value when indicator constraint take effect.

  • const MDOTempConstr& expr – The linear constraint part of new indicator constraint.

  • const std::string& name="" – The name of new indicator constraint.

Returns

The newly added general constraint.

MDOPsdConstr addPsdConstr(const MDOPsdExpr &expr, const char sense, double rhs, const std::string &name = "")

Add a new PSD constraint to this model.

Parameters
  • const MDOPsdExpr& expr – The left-hand-side expression of new PSD constraint.

  • const char sense

    The inequality sign. Supported senses include:

    • MDO_EQUAL

    • MDO_LESS_EQUAL

    • MDO_GREATER_EQUAL

  • double rhs – The right-hand-side value of new PSD variables.

  • const std::string& name="" – The name of new PSD constraint, can be empty string in which case a system generated name will be given.

Returns

The newly added constraint.

MDOPsdVar addPsdVar(int dim, const std::string &name = "")

Add a new PSD variables by indicating its dimension and name.

Parameters
  • int dim – The dimension of new PSD variable, that is, the number of matrix rows (or matrix columns, matrix is square) associated to this new PSD variable.

  • const std::string& name="" – The name of new PSD variable, can be empty string in which case a system generated name will be given.

Returns

The newly added PSD variable.

MDOPsdVar addPsdVar(const MDOMatrix &obj, const std::string &name = "")

Add a new PSD variables by indicating its objective coefficient and name.

Parameters
  • const MDOMatrix& obj – The objective coefficient of the new PSD variable, it should be a square matrix.

  • const std::string& name="" – The name of new PSD variable, can be empty string in which case a system generated name will be given.

Returns

The newly added PSD variable.

MDOConstr addRange(const MDOLinExpr &expr, double lower, double upper, const std::string &name = "")

Add a new range constraint to this model.

Parameters
  • const MDOLinExpr& expr – The linear expression.

  • double lower – The lower bound of expr .

  • double upper – The upper bound of expr .

  • const std::string& name="" – The name of new constraint, an empty string is allowed, in which case a system generated name will be given.

Returns

The newly added constraint.

MDOPsdConstr addRangePsdConstr(const MDOPsdExpr &expr, double lower, double upper, const std::string &name = "")

Add a new range PSD constraint to this model.

Parameters
  • const MDOPsdExpr& expr – The expression of new PSD constraint.

  • double lower – The lower bound of expr .

  • double upper – The upper bound of expr .

  • const std::string& name="" – The name of new PSD constraint, can be empty string in which case a system generated name will be given.

Returns

The newly added constraint.

MDOConstr *addRanges(const MDOLinExpr *expr, const double *lower, const double *upper, const std::string &name = "", int len)

Add an amount of range constraints to this model.

Parameters
  • const MDOLinExpr* expr – The linear expressions of new constraints. 0 will be used if NULL presents.

  • const double* lower – The lower bounds of expr . 0 will be used if NULL presents.

  • const double* upper – The upper bounds of expr . MDO_INFINITY s will be used if NULL presents.

  • const std::string& name="" – The names of new constraints, System generated names will be given if NULL presents.

  • int len – The number of constraints to be added.

Returns

The newly added constraints.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

MDOSOS addSOS(const MDOVar *vars, const double *weights, int len, int type)

Add an SOS constraint to the model

Parameters
  • const MDOVar* vars – Variables included in the new SOS constraint

  • const double* weights – Weights of variables in new SOS constraints

  • int len – Number of variables in the new SOS constraint

  • int type

    The type of the new SOS constraint. Supported types include:

    • MDO_SOS_TYPE1(1)

    A maximum of one variable in a set is not equal to 0.

    • MDO_SOS_TYPE2(2)

    A maximum of two consecutive variables in a set are not equal to 0.

Returns

Newly added SOS constraint

MDOVar addVar(double lb, double ub, double obj, char vtype, const std::string &vname = "")

Add a variable to this model by indicate its lower bound, upper bound, objective coefficient, type and name.

Parameters
  • double lb – The lower bound of new variable.

  • double ub – The upper bound of new variable.

  • double obj – The objective coefficient of new variable.

  • char vtype

    The type of new variable. Supported types include:

    • MDO_CONTINUOUS(‘C’) for continuous variable,

    • MDO_BINARY(‘B’) for binary variable,

    • MDO_INTEGER(‘I’) for integral variable,

    • MDO_SEMICONT(‘S’) for semi-continuous variable,

    • MDO_SEMIINT(‘N’) for semi-integral variable.

  • const std::string& vname="" – The name of new variable, an empty string is allowed, in which case a system generated name will be given.

Returns

The newly added variable.

MDOVar addVar(double lb, double ub, double obj, char vtype, int nonzeros, const MDOConstr *xconstrs, const double *coeffs = NULL, const std::string &name = "")

Add a variable to this model and associate it to exist constraints.

Parameters
  • double lb – The lower bound of new variable.

  • double ub – The upper bound of new variable.

  • double obj – The objective coefficient of new variable.

  • char vtype

    The type of new variable. Supported types include:

    • MDO_CONTINUOUS(‘C’) for continuous variable,

    • MDO_BINARY(‘B’) for binary variable,

    • MDO_INTEGER(‘I’) for integral variable,

    • MDO_SEMICONT(‘S’) for semi-continuous variable,

    • MDO_SEMIINT(‘N’) for semi-integral variable.

  • int nonzeros – The number of constraints to be associated.

  • const MDOConstr* xconstrs – The constraints to be associated.

  • const double* coeffs=NULL – The constraint coefficients to each associated constraint. All coefficients will be set to zero if NULL presents.

  • const std::string& name="" – The name of new variable, an empty string is allowed, in which case a system generated name will be given.

Returns

The newly added variable.

MDOVar addVar(double lb, double ub, double obj, char vtype, const MDOColumn &col, const std::string &name = "")

Add a variable to this model and associate it to exist constraints by indicating a constraint matrix column.

Parameters
  • double lb – The lower bound of new variable.

  • double ub – The upper bound of new variable.

  • double obj – The objective coefficient of new variable.

  • char vtype

    The type of new variable. Supported types include:

    • MDO_CONTINUOUS(‘C’) for continuous variable,

    • MDO_BINARY(‘B’) for binary variable,

    • MDO_INTEGER(‘I’) for integral variable,

    • MDO_SEMICONT(‘S’) for semi-continuous variable,

    • MDO_SEMIINT(‘N’) for semi-integral variable.

  • const MDOColumn& col – The constraint matrix column associated to new variable.

  • const std::string& name="" – The name of new variable, an empty string is allowed, in which case a system generated name will be given.

Returns

The newly added variable.

MDOVar *addVars(int cnt, char type = MDO_CONTINUOUS)

Add cnt typed variables to this model.

Parameters
  • int cnt – Number of variables to be added.

  • char type=MDO_CONTINUOUS

    The type of new variables. Supported types include:

    • MDO_CONTINUOUS(‘C’) for continuous variable,

    • MDO_BINARY(‘B’) for binary variable,

    • MDO_INTEGER(‘I’) for integral variable,

    • MDO_SEMICONT(‘S’) for semi-continuous variable,

    • MDO_SEMIINT(‘N’) for semi-integral variable.

Returns

The newly added variables.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

MDOVar *addVars(const double *lb, const double *ub, const double *obj, const char *type, const std::string *name, int len)

Add an amount of variables.

Parameters
  • const double* lb – The lower bounds of new variables. 0 will be used if NULL presents.

  • const double* ub – The upper bounds of new variables. MDO_INFINITY s will be used if NULL presents.

  • const double* obj – The objective coefficients of new variables, 0 will be used if NULL presents.

  • const char* type

    The types of new variables. Supported types include:

    • MDO_CONTINUOUS(‘C’) for continuous variable,

    • MDO_BINARY(‘B’) for binary variable,

    • MDO_INTEGER(‘I’) for integral variable,

    • MDO_SEMICONT(‘S’) for semi-continuous variable,

    • MDO_SEMIINT(‘N’) for semi-integral variable.

  • const std::string* name – The names of new variables. System generated names will be given if NULL presents.

  • int len – The number of variables to be added.

Returns

The newly added variables.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

MDOVar *addVars(const double *lb, const double *ub, const double *obj, const char *type, const std::string *name, const MDOColumn *col, int len)

Add an amount of variables.

Parameters
  • const double* lb – The lower bounds of new variables. 0 will be used if NULL presents.

  • const double* ub – The upper bounds of new variables. MDO_INFINITY s will be used if NULL presents.

  • const double* obj – The objective coefficients of new variables, 0s will be used if NULL presents.

  • const char* type

    The types of new variables. Supported types include:

    • MDO_CONTINUOUS(‘C’) for continuous variable,

    • MDO_BINARY(‘B’) for binary variable,

    • MDO_INTEGER(‘I’) for integral variable,

    • MDO_SEMICONT(‘S’) for semi-continuous variable,

    • MDO_SEMIINT(‘N’) for semi-integral variable.

  • const std::string* name – The names of new variables. System generated names will be given if NULL presents.

  • const MDOColumn* col – The constraint matrix columns to associated to new variables.

  • int len – The number of variables to be added.

Returns

The newly added variables.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

void chgCoeff(MDOConstr c, MDOVar v, double val)

Change the constraint coefficient in constraint matrix.

Parameters
  • MDOConstr c – The constraint to indicate the coefficient.

  • MDOVar v – The variable to indicate the coefficient.

  • double val – The new coefficient value.

void chgCoeffs(const MDOConstr *xconstrs, const MDOVar *xvars, const double *val, int len)

Change constraint coefficients in constraint matrix.

Parameters
  • const MDOConstr* xconstrs – The constraints to indicate coefficients.

  • const MDOVar* xvars – The variables to indicate coefficients.

  • const double* val – The new coefficient values.

  • int len – The number of coefficient to be changed.

void computeIIS()
Compute an IIS(Irreducible Inconsistent Subsystem). IIS is a subset of variable bounds and constraint bounds, this subset satisfies:
  1. The subproblem corresponding to the subset is still infeasible. 2. After delete any bound in this subset, the subproblem becomes feasible.

Check IIS related attributes for variable and constraint for more details.

Note

The cardinality of the subsystem is supposed to be small. Note that the problem is supposed to be infeasible.

int get(MDO_IntParam param)

Retrieve value of an int parameter by its name.

Parameters

MDO_IntParam param – The parameter name.

Returns

The current value of parameter to be retrieved.

double get(MDO_DoubleParam param)

Retrieve value of a double parameter by its name.

Parameters

MDO_DoubleParam param – The parameter name.

Returns

The current value of parameter to be retrieved.

std::string get(MDO_StringParam param)

Retrieve value of a string parameter by its name.

Parameters

MDO_StringParam param – The parameter name.

Returns

The current value of parameter to be retrieved.

int get(MDO_IntAttr attr)

Retrieve the value of an int attribute.

Parameters

MDO_IntAttr attr – The attribute name.

Returns

The current value of attribute to be retrieved.

double get(MDO_DoubleAttr attr)

Retrieve the value of a double attribute.

Parameters

MDO_DoubleAttr attr – The attribute name.

Returns

The current value of attribute to be retrieved.

std::string get(MDO_StringAttr attr)

Retrieve the value of a string attribute.

Parameters

MDO_StringAttr attr – The attribute name.

Returns

The current value of attribute to be retrieved.

int *get(MDO_IntAttr attr, const MDOVar *xvars, int len)

Retrieve values of named attributes associated to variables.

Parameters
  • MDO_IntAttr attr – The attribute name.

  • const MDOVar* xvars – The associating variables.

  • int len – The number of variables.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

char *get(MDO_CharAttr attr, const MDOVar *xvars, int len)

Retrieve values of named attributes associated to variables.

Parameters
  • MDO_CharAttr attr – The attribute name.

  • const MDOVar* xvars – The associating variables.

  • int len – The number of variables.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

double *get(MDO_DoubleAttr attr, const MDOVar *xvars, int len)

Retrieve values of named attributes associated to variables.

Parameters
  • MDO_DoubleAttr attr – The attribute name.

  • const MDOVar* xvars – The associating variables.

  • int len – The number of variables.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

std::string *get(MDO_StringAttr attr, const MDOVar *xvars, int len)

Retrieve values of named attributes associated to variables.

Parameters
  • MDO_StringAttr attr – The attribute name.

  • const MDOVar* xvars – The associating variables.

  • int len – The number of variables.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

int *get(MDO_IntAttr attr, const MDOConstr *xconstrs, int len)

Retrieve values of named attributes associated to constraints.

Parameters
  • MDO_IntAttr attr – The attribute name.

  • const MDOConstr* xconstrs – The associating constraints.

  • int len – The number of constraints.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

char *get(MDO_CharAttr attr, const MDOConstr *xconstrs, int len)

Retrieve values of named attributes associated to constraints.

Parameters
  • MDO_CharAttr attr – The attribute name.

  • const MDOConstr* xconstrs – The associating constraints.

  • int len – The number of constraints.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

double *get(MDO_DoubleAttr attr, const MDOConstr *xconstrs, int len)

Retrieve values of named attributes associated to constraints.

Parameters
  • MDO_DoubleAttr attr – The attribute name.

  • const MDOConstr* xconstrs – The associating constraints.

  • int len – The number of constraints.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

std::string *get(MDO_StringAttr attr, const MDOConstr *xconstrs, int len)

Retrieve values of named attributes associated to constraints.

Parameters
  • MDO_StringAttr attr – The attribute name.

  • const MDOConstr* xconstrs – The associating constraints.

  • int len – The number of constraints.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

int *get(MDO_IntAttr attr, const MDOPsdVar *psdvars, int len)

Retrieve values of named attributes associated to PSD variables.

Parameters
  • MDO_IntAttr attr – The attribute name.

  • const MDOPsdVar* psdvars – The associating PSD variables.

  • int len – The number of PSD variables.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

std::string *get(MDO_StringAttr attr, const MDOPsdVar *psdvars, int len)

Retrieve values of named attributes associated to PSD variables.

Parameters
  • MDO_StringAttr attr – The attribute name.

  • const MDOPsdVar* psdvars – The associating PSD variables.

  • int len – The number of PSD variables.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

MDOMatrix *get(MDO_MatAttr attr, const MDOPsdVar *psdvars, int len)

Retrieve values of named attributes associated to PSD variables.

Parameters
  • MDO_MatAttr attr – The attribute name.

  • const MDOPsdVar* psdvars – The associating PSD variables.

  • int len – The number of PSD variables.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

double *get(MDO_DoubleAttr attr, const MDOPsdConstr *psdconstrs, int len)

Retrieve values of named attributes associated to PSD constraints.

Parameters
  • MDO_DoubleAttr attr – The attribute name.

  • const MDOPsdConstr* psdconstrs – The associating PSD constraints.

  • int len – The number of PSD constraints.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

std::string *get(MDO_StringAttr attr, const MDOPsdConstr *psdconstrs, int len)

Retrieve values of named attributes associated to PSD constraints.

Parameters
  • MDO_StringAttr attr – The attribute name.

  • const MDOPsdConstr* psdconstrs – The associating PSD constraints.

  • int len – The number of PSD constraints.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

int *get(MDO_IntAttr attr, const MDOGenConstr *xgenconstrs, int len)

Retrieve values of named attributes associated to general constraint.

Parameters
  • MDO_IntAttr attr – The attribute name.

  • const MDOGenConstr* xgenconstrs – The associating general constraints.

  • int len – The number of general constraints.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

std::string *get(MDO_StringAttr attr, const MDOGenConstr *xgenconstrs, int len)

Retrieve values of named attributes associated to general constraints.

Parameters
  • MDO_StringAttr attr – The attribute name.

  • const MDOGenConstr* xgenconstrs – The associating general constraints.

  • int len – The number of general constraints.

Returns

The attribute values to be retrieved.

Note

The pointer returned is a heap allocated array, do not forget to delete it.

double getCoeff(MDOConstr c, MDOVar v)

Retrieve a coefficient value from constraint matrix.

Parameters
  • MDOConstr c – The constraint to indicate the coefficient.

  • MDOVar v – The variable to indicate the coefficient.

Returns

The coefficient value to be retrieved.

MDOColumn getCol(MDOVar v)

Retrieve a column from constraint matrix.

Parameters

MDOVar v – The variable to indicate the column.

Returns

The constraint matrix column to be retrieved.

MDOConstr getConstr(int i)

Retrieve the ith constraint in this model.

Parameters

int i – The index of constraint to be retrieved.

Returns

The constraint.

MDOConstr getConstrByName(const std::string &name)

Retrieve a constraint by its name.

Parameters

const std::string& name – The name of constraint to be Retrieved.

Returns

The constraint

MDOConstr *getConstrs()

Retrieve all constraints in this model.

Returns

All constraints in this model, its length can be known by int attribute MDO_IntAttr_NumConstrs .

Note

The pointer returned is a heap allocated array, do not forget to delete it.

MDOEnv getEnv()

Retrieve the environment associated to this model.

Returns

The model associated environment.

void getGenConstrIndicator(MDOGenConstr genc, MDOVar *binvar, int *binval, MDOLinExpr *expr, char *sense, double *rhs)

Retrieve indicator constraint in this model.

Parameters
  • MDOGenConstr genc – [in] The indicator constraint object.

  • MDOVar* binvar – [out] The place to hold binary variable in this indicator constraint.

  • int* binval – [out] The place to hold binary value when this indicator constraint take effect.

  • MDOLinExpr* expr – [out] The place to hold the linear expression of this indicator constraint.

  • char* sense – [out] The place to hold the constraint sense.

  • double* rhs – [out] The place to hold the right-hand-side value of this indicator constraint.

MDOGenConstr *getGenConstrs()

Retrieve all general constraints in the current model

Returns

Return a list of all general constraints in the model.

MDOQuadExpr getObjective()

Retrieve the objective function of this model.

Returns

The objective function.

MDOPsdConstr getPsdConstr(int i)

Retrieve the ith PSD constraint in this model.

Parameters

int i – The index of PSD constraint to be retrieved.

Returns

The PSD constraint.

MDOPsdConstr *getPsdConstrs()

Retrieve all PSD constraints in this model.

Returns

All PSD constraints in this model, its length can be known by int attribute MDO_IntAttr_NumPsdConstrs .

Note

The pointer returned is a heap allocated array, do not forget to delete it.

MDOPsdVar getPsdVar(int i)

Retrieve the ith PSD variable.

Parameters

int i – The index of PSD variable to be retrieved.

Returns

The PSD variable.

MDOPsdVar *getPsdVars()

Retrieve all PSD variables in this model.

Returns

All PSD variables in this model, its length can be known by int attribute MDO_IntAttr_NumPsdVars .

Note

The pointer returned is a heap allocated array, do not forget to delete it.

MDOLinExpr getRow(MDOConstr c)

Retrieve a row from constraint matrix.

Parameters

MDOConstr c – The constraint to indicate the row.

Returns

The constraint matrix row to be retrieved.

int getSOS(MDOSOS sos, MDOVar *vars, double *weights, int *typeP)

Retrieves the variables and coefficients contained in the SOS constraint.

Parameters
  • MDOSOS sos – [in] SOS constraint

  • MDOVar* vars – [out] The list of variables contained in the SOS constraint.

  • double* weights – [out] The weights of variables contained in the SOS constraint.

  • int* typeP

    [out] typeP[0] indicates the type of the SOS constraint (MDO_SOS_TYPE1 or MDO_SOS_TYPE2).

    • MDO_SOS_TYPE1(1)

    A maximum of one variable in a set is not equal to 0.

    • MDO_SOS_TYPE2(2)

    A maximum of two consecutive variables in a set are not equal to 0.

Returns

The length of the variable list.

Note

In actual use, you usually need to call getSOS twice to get all the information. When this method is called for the first time, vars and weights can pass in NULL. After the list length is obtained, vars and weights with sufficient length can be passed in for the second call.

MDOSOS *getSOSs()

Retrieve all SOS constraints in the current model

Returns

Return a list of all SOS constraints in the model.

MDOVar getVar(int i)

Retrieve the ith variable in this model.

Parameters

int i – The index of variable to be retrieved.

Returns

The ith variable in this model.

MDOVar getVarByName(const std::string &name)

Retrieve a variable by its name.

Parameters

const std::string& name – The name of variable to be retrieved.

Returns

The variable.

MDOVar *getVars()

Retrieve all variables in this model.

Returns

All variables in this model, its length can be known by int attribute MDO_IntAttr_NumVars .

Note

The pointer returned is a heap allocated array, do not forget to delete it.

void optimize()

Start to optimize the model.

void read(const std::string &filename)

Read data into this model from a file.

Parameters

const std::string& filename – The file name. File format and compression type should be encoded in filename as a suffix. Valid file format include .prm, .mst, supported compression types include .gz and .bz2.

void remove(MDOVar v)

Remove variable from this model.

Parameters

MDOVar v – The variable to be removed.

void remove(MDOConstr c)

Remove constraint from this model.

Parameters

MDOConstr c – The constraint to be removed.

void remove(MDOSOS sos)

Remove SOS constraints from this model

Parameters

MDOSOS sos – The SOS constraint to remove

void remove(MDOGenConstr genconstr)

Remove general constraints from this model

Parameters

MDOGenConstr genconstr – The general constraint to remove

void reset()

Reset the model to an unsolved state, discarding any previously computed solution.

void set(MDO_IntParam param, int val)

Set the value of an int parameter.

Parameters
  • MDO_IntParam param – The parameter name.

  • int val – The new value for parameter.

void set(MDO_DoubleParam param, double val)

Set the value of a double parameter.

Parameters
  • MDO_DoubleParam param – The parameter name.

  • double val – The new value for parameter.

void set(MDO_StringParam param, std::string val)

Set the value of a string parameter.

Parameters
  • MDO_StringParam param – The parameter name.

  • std::string val – The new value for parameter.

void set(const std::string &param, const std::string &val)

Set the value of a parameter. Parameter type is depends on parameter name.

Parameters
  • const std::string& param – The parameter name.

  • const std::string& val – The string representation of new value for parameter.

void set(MDO_IntAttr attr, int val)

Set the value of an int attribute.

Parameters
  • MDO_IntAttr attr – The attribute name.

  • int val – The new attribute value.

void set(MDO_DoubleAttr attr, double val)

Set the value of a double attribute.

Parameters
  • MDO_DoubleAttr attr – The attribute name.

  • double val – The new attribute value.

void set(MDO_StringAttr attr, const std::string &val)

Set the value of a string attribute.

Parameters
  • MDO_StringAttr attr – The attribute name.

  • const std::string& val – The new attribute value.

void set(MDO_IntAttr attr, const MDOVar *xvars, const int *val, int len)

Set the values of named attributes associated to variables.

Parameters
  • MDO_IntAttr attr – The attribute name.

  • const MDOVar* xvars – The associating variables.

  • const int* val – The new value for attributes.

  • int len – The number of attributes to be set.

void set(MDO_CharAttr attr, const MDOVar *xvars, const char *val, int len)

Set the values of named attributes associated to variables.

Parameters
  • MDO_CharAttr attr – The attribute name.

  • const MDOVar* xvars – The associating variables.

  • const char* val – The new value for attributes.

  • int len – The number of attributes to be set.

void set(MDO_DoubleAttr attr, const MDOVar *xvars, const double *val, int len)

Set the values of named attributes associated to variables.

Parameters
  • MDO_DoubleAttr attr – The attribute name.

  • const MDOVar* xvars – The associating variables.

  • const double* val – The new value for attributes.

  • int len – The number of attributes to be set.

void set(MDO_StringAttr attr, const MDOVar *xvars, const std::string *val, int len)

Set the values of named attributes associated to variables.

Parameters
  • MDO_StringAttr attr – The attribute name.

  • const MDOVar* xvars – The associating variables.

  • const std::string* val – The new value for attributes.

  • int len – The number of attributes to be set.

void set(MDO_IntAttr attr, const MDOConstr *xconstrs, const int *val, int len)

Set the values of named attributes associated to constraints.

Parameters
  • MDO_IntAttr attr – The attribute name.

  • const MDOConstr* xconstrs – The associating constraints.

  • const int* val – The new value for attributes.

  • int len – The number of attributes to be set.

void set(MDO_CharAttr attr, const MDOConstr *xconstrs, const char *val, int len)

Set the values of named attributes associated to constraints.

Parameters
  • MDO_CharAttr attr – The attribute name.

  • const MDOConstr* xconstrs – The associating constraints.

  • const char* val – The new value for attributes.

  • int len – The number of attributes to be set.

void set(MDO_DoubleAttr attr, const MDOConstr *xconstrs, const double *val, int len)

Set the values of named attributes associated to constraints.

Parameters
  • MDO_DoubleAttr attr – The attribute name.

  • const MDOConstr* xconstrs – The associating constraints.

  • const double* val – The new value for attributes.

  • int len – The number of attributes to be set.

void set(MDO_StringAttr attr, const MDOConstr *xconstrs, const std::string *val, int len)

Set the values of named attributes associated to constraints.

Parameters
  • MDO_StringAttr attr – The attribute name.

  • const MDOConstr* xconstrs – The associating constraints.

  • const std::string* val – The new value for attributes.

  • int len – The number of attributes to be set.

void set(MDO_IntAttr attr, const MDOPsdVar *psdvars, const int *val, int len)

Set the values of named attributes associated to PSD variables.

Parameters
  • MDO_IntAttr attr – The attribute name.

  • const MDOPsdVar* psdvars – The associating PSD variables.

  • const int* val – The new value for attributes.

  • int len – The number of attributes to be set.

void set(MDO_StringAttr attr, const MDOPsdVar *psdvars, const std::string *val, int len)

Set the values of named attributes associated to PSD variables.

Parameters
  • MDO_StringAttr attr – The attribute name.

  • const MDOPsdVar* psdvars – The associating PSD variables.

  • const std::string* val – The new value for attributes.

  • int len – The number of attributes to be set.

void set(MDO_MatAttr attr, const MDOPsdVar *psdvars, const MDOMatrix *val, int len)

Set the values of named attributes associated to PSD variables.

Parameters
  • MDO_MatAttr attr – The attribute name.

  • const MDOPsdVar* psdvars – The associating PSD variables.

  • const MDOMatrix* val – The new value for attributes.

  • int len – The number of attributes to be set.

void set(MDO_DoubleAttr attr, const MDOPsdConstr *psdconstrs, const double *val, int len)

Set the values of named attributes associated to PSD constraints.

Parameters
  • MDO_DoubleAttr attr – The attribute name.

  • const MDOPsdConstr* psdconstrs – The associating PSD constraints.

  • const double* val – The new value for attributes.

  • int len – The number of attributes to be set.

void set(MDO_StringAttr attr, const MDOPsdConstr *psdconstrs, const std::string *val, int len)

Set the values of named attributes associated to PSD constraints.

Parameters
  • MDO_StringAttr attr – The attribute name.

  • const MDOPsdConstr* psdconstrs – The associating PSD constraints.

  • const std::string* val – The new value for attributes.

  • int len – The number of attributes to be set.

void set(MDO_StringAttr attr, const MDOGenConstr *xgenconstrs, const std::string *val, int len)

Set the values of named attributes associated to general constraints.

Parameters
  • MDO_StringAttr attr – The attribute name.

  • const MDOGenConstr* xgenconstrs – The associating general constraints.

  • const std::string* val – The new value for attributes.

  • int len – The number of attributes to be set.

void setCallback(MDOCallback *callback)

Set up a user defined callback class object.

Parameters

MDOCallback* callback – The user defined callback class object.

void setObjective(const MDOLinExpr &obje, int sense = 0)

Set the objective function.

Parameters
  • const MDOLinExpr& obje – The objective function to be set.

  • int sense=0 – The optimization sense. MDO_MAXIMIZE(-1) for maximization, MDO_MINIMIZE(1) for minimization, or other value, in which case the current sense won’t be changed. The default optimization sense is MDO_MINIMIZE.

void setObjective(const MDOQuadExpr &obje, int sense = 0)

Set the objective function.

Parameters
  • const MDOQuadExpr& obje – The objective function to be set.

  • int sense=0 – The optimization sense. MDO_MAXIMIZE(-1) for maximization, MDO_MINIMIZE(1) for minimization, or other value, in which case the current sense won’t be changed. The default optimization sense is MDO_MINIMIZE.

void setObjective(const MDOPsdExpr &obje, int sense = 0)

Set the objective function.

Parameters
  • const MDOPsdExpr& obje – The objective function to be set.

  • int sense=0 – The optimization sense. MDO_MAXIMIZE(-1) for maximization, MDO_MINIMIZE(1) for minimization, or other value, in which case the current sense won’t be changed. The default optimization sense is MDO_MINIMIZE.

void write(const std::string &filename)

Write model data to a file.

Parameters

const std::string& filename – The path to file where data serialized. Note that data type and its compression type (optionally) is encoded in the file name suffix. Valid suffixes are .lp, .mps and .qps for model itself, .sol, .bas, .prm and .mst for solution data, basis data, parameter settings and MIP starts. optionally followed by its compression type .gz or .bz2.