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 tomosek
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:
sense
(string) – Objective sense, e.g."max"
or"min"
c
(numeric_vector) – Objective coefficient array.c0
(numeric) – Objective constant.A
(matrix_sparse) – Linear constraint sparse matrix.bc
(matrix) – Lower and upper constraint bounds.bx
(matrix) – Lower and upper variable bounds.cones
(matrix_list) – Conic or affine conic constraints.F
(matrix_sparse) – Affine conic constraint — sparse matrix. See Sec. 6.2 (From Linear to Conic Optimization).g
(numeric_vector) – Affine conic constraint — constant vector. See Sec. 6.2 (From Linear to Conic Optimization).bardim
(numeric_vector) – Semidefinite variable dimensions. See Sec. 6.7 (Semidefinite Optimization).barc
(list) – Semidefinite objective coefficients. See Sec. 6.7 (Semidefinite Optimization).barA
(list) – Semidefinite constraint coefficients. See Sec. 6.7 (Semidefinite Optimization).barF
(list) – Semidefinite affine conic constarint coefficients. See Sec. 6.7 (Semidefinite Optimization).intsub
(numeric_vector) – Integer variable indexes. See Sec. 6.8 (Integer Optimization).qobj
(list) – The quadratic part of the objective. See Sec. 6.9 (Quadratic Optimization).iparam
(list) – Integer parameter list. See Sec. 7.4 (Setting solver parameters).dparam
(list) – Double parameter list. See Sec. 7.4 (Setting solver parameters).sparam
(list) – String parameter list. See Sec. 7.4 (Setting solver parameters).sol
(solver_solutions
) – Initial solution struct.
- options¶
The options could have any name, and are, in fact, often input directly as an anonymous list.
- Fields:
verbose
(numeric) – Output logging verbosity. See Sec. 7.3.1 (Stream logging).usesol
(bool) – Whether to use the initial solution.useparam
(bool) – Whether to use the specified parameter settings.soldetail
(numeric) – Level of detail used to describe solutions.getinfo
(bool) – Whether to extract MOSEK information items. See Sec. 7.5 (Retrieving information items).writebefore
(string) – File path used to export model. See Sec. 7.3.3 (Saving a problem to a file).writeafter
(string) – File path used to export model and solution. See Sec. 7.3.3 (Saving a problem to a file).
- 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:
itr
(solution_info
) – Interior solution.bas
(solution_info
) – Basic solution.int
(solution_info
) – Integer solution.
- 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 optionsoldetail
).dobjval
(numeric) – Dual objective value (not in integer solution, only available if requested by optionsoldetail
).pobjbound
(numeric) – Best primal objective bound from relaxations (only for integer solution).maxinfeas
(infeas_info
) – Maximal solution infeasibilities (only available if requested by optionsoldetail
).
- 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 bymosek_read
).
- result¶
It contains results for most of the Rmosek functions. Some fields are available only for specific functions.
- Fields:
response
(response
) – Response from the MOSEK optimization library. See Sec. 7.2 (Errors and exceptions).prob
(problem
) – Problem description (only available inmosek_read
).sol
(solver_solutions
) – Available solutions (algorithm/problem dependent) (only available inmosek
).iinfo
(numeric_list) – Integer information list (Only available if requested by optiongetinfo
).dinfo
(numeric_list) – Double information list (Only available if requested by optiongetinfo
).