R is a programming language and open source software environment for statistical computing and graphics. It has excellent support for retrieving data from offline and online data sources, and the R-to-MOSEK Optimization Interface allows you to channel this information directly into optimization problems. Even better, the computed solutions can be verified, visualized or further analyzed by the wide range of R tools.
The R-to-MOSEK Optimization Interface is distributed as a package called
Rmosek on the
CRAN repository. In this way, the latest release and bugfixes are never more than a single command away from your R software environment.
The Rmosek package is minimalistic in the sense that you formulate your optimization problems using standard R functionality and primitive variables. The problem structure can thus be built, loaded and saved in the fastest or easiest way, relative to the R programming language, and then pushed to the optimization engine with little overhead.
The optimization interface allows the user to solve:
Linear optimization problems.
Conic optimization problems (with second-order cones and semidefinite matrices).
Convex quadratic optimization problems.
Mixed-integer linear and conic optimization problems.
Separable convex optimization problems.
The following is a conic optimization problem with six variables, one linear constraint, and two second-order cones:
To construct this, we fill a list with data from the linear part of the problem.
- cqo1 <- list(sense = "min")
- cqo1$c <- c(0,0,0,1,1,1)
- cqo1$A <- Matrix(c(1,1,2,0,0,0),
- nrow=1, sparse=TRUE)
- cqo1$bc <- rbind(blc = c(1),
- buc = c(1))
- cqo1$bx <- rbind(blx = c(0,0,0,-Inf,-Inf,-Inf),
- bux = rep(Inf,6))
Separately, the quadratic and rotated quadratic cone is specified.
- cqo1$cones <- cbind(list("QUAD", c(4,1,2)),
- list("RQUAD", c(5,6,3)))
So far we have not used the Rmosek package. It does, however, come to play when we solve the problem.
- r <- mosek(cqo1)
The given result contains the computed solution along with human and computer readable status codes to interpret it.