R Logo R-forge Logo MOSEK Logo

Welcome to The R-to-MOSEK Optimization Interface project!

Purpose

The R-to-MOSEK Optimization Interface is designed to make the optimization facilities of MOSEK available from R. MOSEK is a software library able to solve many kinds of large-scale optimization problems, and this interface currently supports:


Furthermore, as an advanced feature, the interface supports:


Note that the MOSEK libraries ships with trial and academic licenses free of charge, but is otherwise a proprietary product.


System Requirements

You need MOSEK!
Only MOSEK version 6.0.0.122 and newer are supported. Free trial and academic licenses are available, and quotations can be requested to allow commercial usage.
You need R!
64bit R for a 64bit MOSEK, or 32bit R for a 32 bit MOSEK installation.
You need a build chain!
This is a source package, and so must be compiled before it can be used. Windows users may install R-tools for this purpose.

You also need the Matrix package, but this has been part of the default installation of R since version 2.9.0. Please call update.packages("Matrix") from the R-console to make sure that you have the newest version installed.


Installation

The 'Rmosek' package features auto-configuration which will work in most cases if the system has been properly set up (see System Requirements). Most users will be able to install the package with:

install.packages("Rmosek", type="source")



where R and MOSEK have the same architecture (32/64bit). If this does not work, we advice you to look in the userguide.pdf for more information. Notice that the source code of the 'Rmosek' package can be obtained from CRAN.


Getting started

The package can be loaded with

require(Rmosek)

The provided functions can be seen with

library(help="Rmosek")

The manual for each function (here mosek) can be found with

help("mosek", package="Rmosek")

The "mosek" function is used to solve all supported optimization problems.

Example 1: In this example a linear program is defined and solved.

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)

Example 2: In this example the formulation of a mixed integer linear program is read from a file and solved. The first line finds the path of the "milo1.opf" file within the package directory. Alternatives are "lo1.opf" and "cqo1.opf".

modelfile <- system.file(package="Rmosek", "extdata", "milo1.opf")
r_read <- mosek_read(modelfile)
r_solve <- mosek(r_read$prob)

Tips and tricks, questions, feature requests and bug reports

We invite all users of the R-to-MOSEK Interface to join our central MOSEK discussion group. This group is particularly intended for academics using MOSEK in their research.

Featured
Downloads

>> Source code

>> Userguide

>> Examples