Learn R Programming

Rmosek (version 0.9.4)

mosek: Solve an optimization problem

Description

Solve an optimization problem using the MOSEK Optimization Library.

Please see the 'userguide.pdf' for a detailed introduction to this pacakge. This file is located at the root of this package: system.file("userguide.pdf", package="Rmosek")

Usage

mosek(problem, opts = list())

Arguments

problem
The optimization problem. lll{ problem LIST ..$sense STRING ..$c NUMERIC VECTOR ..$c0 NUMERIC (OPTIONAL) ..$A SPARSE MATRIX ..$blc NUMERIC VECTOR ..$buc NUMERIC VECTOR ..$blx NUMERIC
opts
The interface options. lll{ opts LIST (OPTIONAL) ..$verbose NUMERIC (OPTIONAL) ..$usesol BOOLEAN (OPTIONAL) ..$useparam BOOLEAN (OPTIONAL) ..$writebefore STRING (filepath) (OPTIONAL) ..$writeafter

Value

  • rThe returned results. lll{ r LIST ..$response LIST ....$code NUMERIC ....$msg STRING ..$sol LIST ....$itr/$bas/$int LIST (SOLVER DEPENDENT) ......$solsta STRING ......$prosta STRING ......$skx STRING VECTOR ......$skc STRING VECTOR ......$xx NUMERIC VECTOR ......$xc 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) }
  • The result is a named list containing the response of the MOSEK Optimization Library. Note that the result can be NULL if interfacing errors are encountered.

    Depending on the specified solver, one or more solutions mays 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 definition. 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. 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 ...$skx Variable bound keys ...$skc Constraint bound keys ...$xx Variable activities ...$xc Constraint 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 }

Details

The optimization problem should be specified 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. The constraints can either be linear, specified as rows in A with lower bounds blc and upper bounds buc (you can use Inf if needed), or conic as specified in the list cones (add constraints copyx=x if some variable x appears in multiple cones). Each variable is bounded by blx and bux and will be integer if it appears in the intsub list.

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 modelling 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. ll{ problem Problem description .$sense Objective sense, e.g. "max" or "min" .$c Objective coefficients .$c0 Objective constant .$A Constraint matrix .$blc Constraint lower bounds .$buc Constraint upper bounds .$blx Variable lower bounds .$bux Variable upper bounds .$cones Conic constraints ..$type Cone type ..$sub Cone variable indexes .$intsub Integer variable indexes .$iparam/$dparam/$sparam Parameter list ..$ Value of any .$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 .$writebefore Filepath used to export model .$writeafter Filepath used to export model and solution }

See Also

mosek_version mosek_clean

Examples

Run this code
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$blc <- c(30,15,-Inf)
 lo1$buc <- c(30,Inf,25)
 lo1$blx <- c(0,0,0,0)
 lo1$bux <- c(Inf,10,Inf,Inf)
 r <- mosek(lo1)

Run the code above in your browser using DataLab