# 5 Guidelines¶

## 5.1 Parallel optimization Using the The Multicore Package¶

The R package called multicore, provides functions for parallel execution of R code on machines with multiple cores or CPUs. Windows is not currently supported, but the package should work on most UNIX-alike platforms.

The multicore package works by copying the full memory state of the R session to new processes. While this seems like a large overhead, in practice, the copy is delayed until modification assuring a smooth parallel execution. The downside is that this low-level memory state copy is not safe for all types of resources. As an example, parallel interactions with the GUI or on-screen devices can cause the R session to crash. It is thus recommended only to use the multicore package in console R.

In the Rmosek package a license is an externally acquired resource, and attempts to simply copy the memory state of this resource will provoke a session crash. Thus, licenses should always be released before the time of parallelization.

Note

Always call mosek_clean() before a parallelizing operator. Failure to do so is likely to provoke session crashes.

A consequence of this is that each new process will be using a separate license. That is, your license system should allow 8 licenses to be checked out simultaneously, if you wish to solve 8 optimization problems in parallel. Please note that unlimited academic and commercial licenses are available at MOSEK.