4 Installation

In this section we discuss how to install and setup the MOSEK Rmosek package.

Important

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.

Compatibility

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.

Table 4.1 Relevant files for the Rmosek package.

Relative Path

Description

Label

<MSKHOME>/mosek/11.0/tools/platform/<PLATFORM>/rmosek

Rmosek install files

<RMOSEKDIR>

<MSKHOME>/mosek/11.0/tools/examples/rmosek

Examples

<EXDIR>

<MSKHOME>/mosek/11.0/tools/examples/data

Additional data

<MISCDIR>

where

  • <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. win64x86, linux64x86 , linuxaarch64 or osxaarch64.

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.

Windows

  • Download Rtools (not an R package). You will need to install the R toolset, the Cygwin DLLs, and the toolchain.

  • Make sure you have mosek and the executables of Rtools on the PATH environment variable.

MacOS

  • Make sure you have Xcode installed.

Linux

  • On Ubuntu (and Debian) you may install the r-base-dev package.

4.2 Installation

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., mosek/<MSKVER>/tools/platform/<PLATFORM>/bin.

  • 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

require("Rmosek")

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