8.8.1. MATLAB functions

MindOpt MATLAB functions.

Functions

mindopt()

This function is used to optimize the provided model

mindopt_iis()

Compute an IIS(Irreducible Inconsistent Subsystem)

mindopt_read()

Read a model from the file

mindopt_write()

Serialize model data to file

mindopt(model, params[optional])

This function is used to optimize the provided model. It will automatically call the appropriate algorithm based on the type of model. Regardless of whether the optimization is successful or not, a MATLAB structure variable containing information related to the optimization will be returned.

Parameters
  • model – a MATLAB structure for models, must include valid MindOpt model field. For specific details, please refer to the Model section.

  • params[optional] – a MATLAB structure for params. It must contain valid mindopt parameter fields. For more details, you can refer to the parameters section. In order to comply with MATLAB’s legality for field names, the ‘/’ in the parameters will be replaced by ‘_’. For example, you can specify the value of the parameter “MIP/MaxNodes” by inputing params.MIP_MaxNodes.

Returns

The mindopt() function returns a structure wherein various optimization results are stored within its fields. The specific results available depend on the type of model being solved, the parameters used, and the optimization status. The returned results include the following attributes. Status, ObjVal, X, RC, SolverTime, PresolverTime, SolutionTime, MIP_GapAbs, MIP_GapRel, IPM_NumIters, SPX_NumIters. Among these, the values of ObjVal and X are valid only when the solution status is ‘OPTIMAL’. The MIP_GapAbs and MIP_GapRel are valid only when solving Mixed-Integer Programming (MIP) problems. The IPM_NumIters is valid only when the Interior Point Method (IPM) is employed. The SPX_NumIters is valid only when the Simplex method is is employed.

example:

result = mindopt(model, params);
if strcmp(result.Status, 'OPTIMAL')
    fprintf('Optimal objective: %e\n', result.ObjVal);
    disp(result.X);
else
    fprintf('Optimization returned status: %s\n', result.Status);
end
mindopt_iis(model, params[optional])

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.

Parameters
  • model – MATLAB structure for models, must include valid MindOpt model field. For specific details, please refer to the Model section.

  • params[optional] – MATLAB structure for params. It must contain valid mindopt parameter fields. For more details, you can refer to the parameters section. In order to comply with MATLAB’s legality for field names, the ‘/’ in the parameters will be replaced by ‘_’. For example, you can specify the value of the parameter “MIP/MaxNodes” by inputing params.MIP_MaxNodes.

Returns

The returned results include the following attributes. Status, IISRow, IISCol. IISRow means if the left-hand-side value and (or) right-hand-side value of this constraint belong to IIS. The specific meaning of the value refers to the constraint attribute IISRow. IISCol means if the upper and (or) lower bound(s) of this variable belong to IIS.The specific meaning of the value refers to the variable attribute IISCol.

example:

iis = mindopt_iis(model, params);
if strcmp(iis.Status, 'OPTIMAL')
    fprintf('The model is OPTIMAL.\n');
else
    fprintf('Optimization returned status: %s\n', iis.Status);
    fprintf('IISvar\n');
    disp(iis.IISVar);
end
mindopt_read(filename, params[optional])

Read a model from the file. Note that file format and its compression type (optionally) is encoded in the file name suffix. Valid sußffixes are: .lp, .mps, .qps and .dat-s, optionally followed by its compression type .gz or .bz2. The mindopt_read() function is used to read a model and write the results into a MATLAB structure. When setting the attributes of the model, the mindopt_read() function follows these rules:

  • For various types of constraints, if they do not exist, the corresponding attribute fields will not be present in the model that is read.

  • For linear and quadratic constraints, the lhs and rhs will be used to represent the range of the constraints instead of using sense and rhs. When lhs and rhs are equal, it indicates that the constraint is an ‘=’ constraint; when lhs is -1e20 (defined in mindopt as positive infinity), it indicates that the constraint is a ‘>’ constraint; when rhs is 1e20 (defined in mindopt as negative infinity), it indicates that the constraint is a ‘<’ constraint. Both lhs and rhs will be n*1 arrays.

  • For varnames, a cell array of length equal to the number of variables will be read; for constrnames, a cell array of length equal to the number of linear constraints will be read. The values read will be the variable names and constraint names from the model file.

  • For vtype, an array of characters of the same length as the number of variables will be read, where each character represents the type of the corresponding variable.

  • For quadcon, the read quadratic constraint terms will be represented by Qrow, Qcol, and Qval, forming an upper triangular matrix with dimensions equal to the number of variables. The read quadcon will not include the Qc attribute field. The linear constraint terms q will be represented using a dense one-dimensional vector.

  • For genconind, the constraints’ ranges will be represented using the read rhs and sense. The linear constraint terms a will be represented using a dense one-dimensional vector.

If a user first writes a constructed model modelA to a model file using the mindopt_write() function and then reads that model file using the mindopt_read() function to obtain modelB, the above rules may lead to some differences in the attribute values between modelA and modelB. However, this will not affect the solution, and both modelA and modelB can yield the same results.

Parameters
  • filename – Path of the model file. Must be a char array.

  • params[optional] – MATLAB structure for params. It must contain valid mindopt parameter fields. For more details, you can refer to the parameters section. In order to comply with MATLAB’s legality for field names, the ‘/’ in the parameters will be replaced by ‘_’. For example, you can specify the value of the parameter “MIP/MaxNodes” by inputing params.MIP_MaxNodes.

Returns

The return value is a matlab structure for models, must include valid MindOpt model field. For specific details, please refer to the model section.

example:

model = mindopt_read('a.mps');
result = mindopt(model);
mindopt_write(model, filename, params[optional])

Serialize model data to file. Include model itself or other settings. 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.

Parameters
  • model – model: a MATLAB structure for models, must include valid MindOpt model field. For specific details, please refer to the model section.

  • filename – The path to file where data serialized. Must be a char array.

  • params[optional] – MATLAB structure for params. It must contain valid mindopt parameter fields. For more details, you can refer to the parameters section. In order to comply with MATLAB’s legality for field names, the ‘/’ in the parameters will be replaced by ‘_’. For example, you can specify the value of the parameter “MIP/MaxNodes” by inputing params.MIP_MaxNodes.

example:

model = mindopt_read('a.mps');
mindopt_write(model, 'b.mps');
result = mindopt(model);