In this section we discuss how to install and setup the MOSEK Rmosek package.
Before running this MOSEK interface please make sure that you:
Installed MOSEK correctly. Some operating systems require extra steps. See the Installation guide for instructions and common troubleshooting tips.
Set up a license. See the Licensing guide for instructions.
The Rmosek package can be used with R version at least 3.6.
Locating files in the MOSEK Optimization Suite
The relevant files for the Rmosek package are organized as reported in Table 4.1.
Rmosek install files
<MSKHOME>is the folder in which the MOSEK Optimization Suite has been installed,
<PLATFORM>is the actual platform among those supported by MOSEK, i.e.
4.1 System requirements¶
There are no pre-compiled binary versions of the Rmosek package available, so the system must be able compile C++ source code and have access to a few command line tools. The summary of relevance to the Rmosek package given below is based on the official guide, R Installation and Administration, for installing packages in source form.
Download Rtools (not an R package). You will need to install the R toolset, the Cygwin DLLs, and the toolchain.
Make sure you have
mosekand the executables of Rtools on the
Make sure you have
On Ubuntu (and Debian) you may install the
To install the Rmosek package you may run the
install.rmosek function of the script
<RMOSEKDIR>/builder.R. This is a wrapper around the
install.packages function with recommended default argument values (e.g., to a compatible MOSEK repository), cross-platform support of configurations variables, and helpers to resolve Rtools on Windows. As example, if called with no arguments, it will attempt an autoconfigured installation:
source("<RMOSEKDIR>/builder.R") attachbuilder() install.rmosek()
You can inspect the autoconfigured defaults by typing
show(install.rmosek). Apart from the typical arguments of
install.packages, a user might want to change:
MSK_BINDIR: The location of the MOSEK library to compile against; e.g.,
using_pkgbuild: Whether to run the installation in the build-friendly environment of package
pkgbuild(helps, e.g., to resolve Rtools on Windows).
using_sysenv: Whether to transmit configuration variables via
Sys.setenv()as opposed to
configure.vars(depends on platform support).
4.3 Testing the Installation¶
First of all, to check that the Rmosek package was properly installed, start R and try
The installation can further be tested by running some of the enclosed examples. Open a terminal, change folder to
<EXDIR> and use R to run a selected example, for instance:
R -f lo1.R