Solve an optimization problem using the MOSEK Optimization Library.
Please see the 'userguide.pdf' for a detailed introduction to this package.
This file is located in the "doc" directory at the root of this package:
system.file("doc", "userguide.pdf", package="Rmosek")
mosek(problem, opts = list())
The optimization problem.
problem | LIST | |
..$sense | STRING | |
..$c | NUMERIC VECTOR | |
..$c0 | NUMERIC | (OPTIONAL) |
..$A | SPARSE MATRIX | |
..$bc | NUMERIC MATRIX (2 rows) | |
..$bx | NUMERIC MATRIX (2 rows) | |
..$cones | LIST MATRIX (2 rows) | (OPTIONAL) |
..$intsub | NUMERIC VECTOR | (OPTIONAL) |
..$qobj | LIST | (OPTIONAL) |
..$scopt | LIST | (OPTIONAL) |
..$iparam/$dparam/$sparam | LIST | (OPTIONAL) |
....$<MSK_PARAM> | STRING / NUMERIC | (OPTIONAL) |
..$sol | LIST | (OPTIONAL) |
....$itr/$bas/$int | LIST | (OPTIONAL) |
The interface options.
opts | LIST | (OPTIONAL) |
..$verbose | NUMERIC | (OPTIONAL) |
..$usesol | BOOLEAN | (OPTIONAL) |
..$useparam | BOOLEAN | (OPTIONAL) |
..$soldetail | NUMERIC | (OPTIONAL) |
..$getinfo | BOOLEAN | (OPTIONAL) |
..$writebefore | STRING (filepath) | (OPTIONAL) |
..$writeafter | STRING (filepath) | (OPTIONAL) |
The returned results.
r | LIST | |
..$response | LIST | |
....$code | NUMERIC | |
....$msg | STRING | |
..$sol | LIST | |
....$itr/$bas/$int | LIST | (SOLVER DEPENDENT) |
......$solsta | STRING | |
......$prosta | STRING | |
......$skc | STRING VECTOR | |
......$skx | STRING VECTOR | |
......$skn | STRING VECTOR | (NOT IN $bas) |
......$xc | NUMERIC VECTOR | |
......$xx | NUMERIC VECTOR | |
......$slc | NUMERIC VECTOR | (NOT IN $int) |
......$suc | NUMERIC VECTOR | (NOT IN $int) |
......$slx | NUMERIC VECTOR | (NOT IN $int) |
......$sux | NUMERIC VECTOR | (NOT IN $int) |
......$snx | NUMERIC VECTOR | (NOT IN $int/$bas) |
......$pobjval | NUMERIC | * |
......$dobjval | NUMERIC | *(NOT IN $int) |
......$pobjbound | NUMERIC | *($int ONLY) |
......$maxinfeas | LIST | * |
........$pbound | NUMERIC | * |
........$peq | NUMERIC | * |
........$pcone | NUMERIC | *(NOT IN $bas) |
........$dbound | NUMERIC | *(NOT IN $int) |
........$deq | NUMERIC | *(NOT IN $int) |
........$dcone | NUMERIC | *(NOT IN $int/$bas) |
........$int | NUMERIC | *($int ONLY) |
..$iinfo/$dinfo | LIST | * |
....$<MSK_INFO> | NUMERIC | * |
*Starred items must be requested using an option. |
The result is a named list containing the response of the MOSEK optimization library. A response code of zero is the signal of success.
Depending on the specified solver, one or more solutions may be returned. The interior-point solution itr, the basic (corner point) solution bas, and the integer solution int.
The problem status prosta in all solutions shows the feasibility of your problem description. All solutions are described by a solution status solsta (e.g. optimal) along with the variable and constraint activities. All activities will further have a bound key that specify their value in relation to the declared bounds.
Dual variables are returned for all defined bounds wherever possible. Integer solutions int does not have any dual variables as such definitions would not make sense. Basic (corner point) solutions bas would never be returned if the problem had conic constraints, and does not define snx.
Setting option soldetail larger than 1 extracts pobjval, pobjval and pobjbound. Larger than 2 extracts maxinfeas. Setting option getinfo to TRUE extracts iinfo and dinfo. lll r Result .$response Response from the MOSEK Optimization Library ..$code ID-code of response ..$msg Human-readable message .$sol All solutions identified ..$itr/$bas/$int Solution description ...$solsta Solution status ...$prosta Problem status ...$skc Linear constraint status keys ...$skx Variable bound status keys ...$skn Conic constraint status keys ...$xc Constraint activities ...$xx Variable activities ...$slc Dual variable for constraint lower bounds ...$suc Dual variable for constraint upper bounds ...$slx Dual variable for variable lower bounds ...$sux Dual variable for variable lower bounds ...$snx Dual variable of conic constraints ...$pobjval Primal objective value ...$dobjval Dual objective value ...$pobjbound Best primal objective bound from relaxations ...$maxinfeas Maximal solution infeasibilities ....$pbound Primal inequality constraints ....$peq Primal equality constraints ....$pcone Primal cone constraints ....$dbound Dual inequality constraints ....$deq Dual equality constraints ....$dcone Dual cone constraints ....$int Integer variables .$iinfo/$dinfo MOSEK information list ..$<MSK_INFO> Value of any <MSK_INFO>
The optimization problem should be described in a named list of definitions.
The number of variables in the problem is determined from the number of
columns in the constraint matrix A
.
Like a Linear Program it has a linear objective with one coefficient in
c
for each variable, some optional constant c0
, and the improving
direction sense
. Quadratic terms can be added to the objective with
qobj
. The constraints can either be linear, specified as rows in
A
with lower and upper bounds as columns in bc
(you can use
Inf
if needed), or conic as specified in the list-typed matrix
cones
(add constraints copyx=x if some variable x appears in multiple
cones). All variables have lower and upper bounds as columns in bx
,
and will be integer if they appear in the intsub
list.
As an advanced feature, non-linear unary operators involving exponential or
logarithmic functions can be added with scopt
. Parameters can also be
specified for the MOSEK call. iparam
is integer-typed parameters,
dparam
ia double-typed parameters and sparam
is string-typed
parameters. These parameters can be ignored by setting the option
useparam
to FALSE (the default is TRUE).
Initial solutions are specified in sol
and should have the same format
as the solution returned by the function call. This solution can be ignored by
setting the option usesol
to FALSE (the default is TRUE).
The amount of information printed by the interface can be limited by
verbose
(default=10). The generated model can be exported to any
standard modeling fileformat (e.g. lp, opf, lp or mbt), with (resp. without)
the identified solution using writeafter
(resp. writebefore
).
The optimization process can be terminated at any moment using CTRL + C.
problem | Problem description |
.$sense | Objective sense, e.g. "max" or "min" |
.$c | Objective coefficients |
.$c0 | Objective constant |
.$A | Constraint matrix |
.$bc | Lower and upper constraint bounds |
.$bx | Lower and upper variable bounds |
.$qobj | Quadratic objective terms |
.$cones | Conic constraints |
.$intsub | Integer variable indexes |
.$scopt | Separable convex optimization |
.$iparam/$dparam/$sparam | Parameter list |
..$<MSK_PARAM> | Value of any <MSK_PARAM> |
.$sol | Initial solution list |
..$itr/$bas/$int | Initial solution description |
opts | Options |
.$verbose | Output logging verbosity |
.$usesol | Whether to use the initial solution |
.$useparam | Whether to use the specified parameter settings |
.$soldetail | Level of detail used to describe solutions. |
.$getinfo | Whether to extract MOSEK information items |
.$writebefore | Filepath used to export model |
.$writeafter | Filepath used to export model and solution |
# NOT RUN {
lo1 <- list()
lo1$sense <- "max"
lo1$c <- c(3,1,5,1)
lo1$A <- Matrix(c(3,1,2,0,
2,1,3,1,
0,2,0,3), nrow=3, byrow=TRUE, sparse=TRUE)
lo1$bc <- rbind(blc = c(30,15,-Inf),
buc = c(30,Inf,25))
lo1$bx <- rbind(blx = c(0,0,0,0),
bux = c(Inf,10,Inf,Inf))
r <- mosek(lo1, list( soldetail = 1 ))
# }
Run the code above in your browser using DataLab