# 13.1 Command Reference¶

The Rmosek interface is composed of a small set of functions and structures.

## 13.1.1 Functions¶

r = mosek(prob, opts)

Solve an optimization problem using the MOSEK optimization library. This is the main interface to MOSEK.

Parameters
Return

r (result) – A structure containing solutions and other results. See Sec. 7.1 (Accessing the solution).

ver = mosek_version()

Retrieves a string containing the version number of the utilized MOSEK optimization library.

Return

ver (string) – The version number.

void = mosek_clean()

Forces the early release of any previously acquired MOSEK license. If you do not share a limited number of licenses among multiple users, you do not need to use this function. The acquisition of a new MOSEK license will automatically take place at the next call to the function mosek given a valid problem description, using a small amount of extra time.

For advanced users: If you utilize the .Call convention directly, i.e. bypassing the mosek R-function definition, an Rf_error will result in an unclean memory space. For this reason you can also use this function to tidy up uncleaned resources in case an error occurs. Otherwise this cleaning will not happen until the next call to mosek or until the library is unloaded. This usage have not been documented elsewhere.

out = mosek_read(filepath, opts = list())

Reads a file in any of the standard file formats (e.g. lp, opf, mps, task, etc.), controlled by a set of options. The result contains an optimization problem which is compliant with the input specifications of function mosek. See Sec. 7.3.4 (Reading a problem from a file).

Parameters
• filepath (string) – A string describing the path to file, either absolute or relative to the working directory. The specified location will be the source of the optimization model to be read.

• opts (io_options) – The options could have any name, and are, in fact, often input directly as an anonymous list.

Return

out (result) – A structure containing the problem that has been read.

r = mosek_write(prob, filepath, opts)

Outputs a model of an optimization problem in a file format (see Sec. 14 (Supported File Formats)), controlled by a set of options. The modeling file format is selected based on the extension of the file. See Sec. 7.3.3 (Saving a problem to a file).

Parameters
• prob (problem) – A structure containing the optimization problem.

• filepath (string) – The input variable should be a string describing the path to the file. This path can either be absolute or relative to the working directory, and will overwrite any existing data on this location. The specified location will be the destination of the exported model.

• opts (io_options) – The options could have any name, and are, in fact, often input directly as an anonymous list.

Return

out (result) – Function response.

## 13.1.2 Structures and Data Types¶

problem

A list object describing the optimization problem using the following fields. Most fields are optional.

Fields
options

The options could have any name, and are, in fact, often input directly as an anonymous list.

Fields
solver_solutions

It contains informations about initial/final solutions. Availability of solutions depends on the problem/algorithm type, see Sec. 7.1.2 (Available solutions).

Fields
solution_info

Stores information about one solution. See Sec. 7.1.2 (Available solutions).

Fields
• solsta (string) – Solution status (solsta).

• prosta (string) – Problem status (prosta).

• skc (string_vector) – Linear constraint status keys (stakey).

• skx (string_vector) – Variable bound status keys (stakey).

• skn (string_vector) – Conic constraint status keys (stakey, not in basic or integer solution).

• xc (numeric_vector) – Constraint activities, i.e., $$x_c = Ax$$ where $$x$$ is the optimal solution.

• xx (numeric_vector) – Variable activities.

• accval (numeric_vector) – Affine conic constraint activities, i.e. $$\text{val}_{\text{acc}} = Fx+g$$ where $$x$$ is the optimal solution.

• barx (list(numeric_vector)) – Semidefinite variable activities (not in basic solution).

• slc (numeric_vector) – Dual variable for constraint lower bounds (not in integer solution).

• suc (numeric_vector) – Dual variable for constraint upper bounds (not in integer solution).

• slx (numeric_vector) – Dual variable for variable lower bounds (not in integer solution).

• sux (numeric_vector) – Dual variable for variable upper bounds (not in integer solution).

• snx (numeric_vector) – Dual variable of conic constraints (not in basic or integer solution).

• doty (numeric_vector) – Dual variable of affine conic constraints (not in basic or integer solution).

• bars (list(numeric_vector)) – Dual variable of semidefinite domains (not in basic or integer solution).

• pobjval (numeric) – Primal objective value (only available if requested by option soldetail).

• dobjval (numeric) – Dual objective value (not in integer solution, only available if requested by option soldetail).

• pobjbound (numeric) – Best primal objective bound from relaxations (only for integer solution).

• maxinfeas (infeas_info) – Maximal solution infeasibilities (only available if requested by option soldetail).

infeas_info

It contains information about the maximal solution infeasibility for several problem items. This struct is only available if the option soldetail is specified.

Fields
• pbound (numeric) – In primal inequality constraints.

• peq (numeric) – In primal equality constraints.

• pcone (numeric) – In primal cone constraints.

• dbound (numeric) – In dual inequality constraints.

• deq (numeric) – In dual equality constraints.

• dcone (numeric) – In dual cone constraints.

• int (numeric) – In integer variables.

io_options

It is used to specify options for input/output operations.

Fields
• verbose (numeric) – Output logging verbosity.

• usesol (bool) – Whether to write an initial solution.

• useparam (bool) – Whether to write all parameter settings.

• getinfo (bool) – Whether to extract MOSEK information items.

• matrixformat (matrix_sparse) – The sparse format of the constraint matrix (only used by mosek_read).

result

It contains results for most of the Rmosek functions. Some fields are available only for specific functions.

Fields
response

Contains a response code from the solver. See rescode for a list.

Fields
• code (numeric) – Numeric value of the response code.

• msg (string) – Human-readable message.