Linear System Solvers

The linear system solver is a core part of the OSQP algorithm. Depending on the problem instance, different linear system solvers can greatly speedup or reduce the computation time of OSQP. To set the preferred linear system solver, see Linear Systems Solvers.

Dynamic shared library loading

OSQP dynamically loads the shared libraries related to the selected external solver. Thus, there is no need to link it at compile time. The only requirement is that the shared library related to the solver is in the library path of the operating system

Operating system

Path variable

Extension

Linux

LD_LIBRARY_PATH

.so

Mac

DYLD_LIBRARY_PATH

.dylib

Windows

PATH

.dll

QDLDL

OSQP comes with QDLDL internally installed. It does not require any external shared library. QDLDL is a sparse direct solver that works well for most small to medium sized problems. However, it becomes not really efficient for large scale problems since it is not multi-threaded.

MKL Pardiso

MKL Pardiso is an efficient multi-threaded linear system solver that works well for large scale problems part of the Intel Math Kernel Library. Intel offers free lincenses for MKL for most non-commercial applications.

Install with MKL

We can install MKL Pardiso by using the standard MKL installer. The main library to be loaded is called libmkl_rt. To add it, together with its dependencies, to your path, just execute the automatic MKL script.

Operating system

Script

Linux

source $MKLROOT/bin/mklvars.sh intel64

Mac

source $MKLROOT/bin/mklvars.sh intel64

Windows

%MKLROOT%mklvars.bat intel64

where MKLROOT is the MKL installation directory.

Install with Anaconda

Anaconda Python distribution comes with the intel MKL libraries preinstalled including MKL Pardiso. To use this version, the Anaconda libraries folders have to be in your system path. Anaconda environments should add them automatically so in most cases you do not have to do anything. If you get an error where OSQP cannot find MKL, you can add the right path by adding the output from the following command to your path variable:

echo "`ls -rd ${CONDA_ROOT}/pkgs/*/ | grep mkl-2 | head -n 1`lib:`ls -rd ${CONDA_ROOT}/pkgs/*/ | grep intel-openmp- | head -n 1`lib"

where ANACONDA_ROOT is the root of your anaconda installation.