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.
Relative Path |
Description |
Label |
---|---|---|
|
Rmosek install files |
|
|
Examples |
|
|
Additional data |
|
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
orosxaarch64
.
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 thePATH
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 packagepkgbuild
(helps, e.g., to resolve Rtools on Windows).using_sysenv
: Whether to transmit configuration variables viaSys.setenv()
as opposed toconfigure.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