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 4.1.
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 in R, i.e.win64x86,linux64x86,osxaarch64andlinuxaarch64.
4.1 System requirements¶
Rmosek requires the Matrix package.
Rmosek is a source package and requires a C++ compiler toolchain to be installed. That typically means that the packages devtools and pkgbuild should be installed, or
alternatively the Rtools on Windows. We refer to the R documentation for details about compiling and installing source packages, for instance https://cran.r-project.org/doc/manuals/R-admin.html#Installing-packages .
The default installation described in the subsequent section will download Rmosek from an online repository, so an Internet connection is required. If you need to install offline, follow the instructions at https://docs.mosek.com/latest/faq/faq.html#rmosek-can-i-install-rmosek-offline .
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