oxfordcontrol / Clarabel.cpp

Clarabel.cpp: C/C++ interface to the Clarabel Interior-point solver for convex conic optimisation problems.
Apache License 2.0
32 stars 10 forks source link
c conic-optimization conic-programs convex-optimization cpp interior-point-method linear-programming optimization optimization-algorithms quadratic-programming semidefinite-programming

FeaturesInstallationLicenseDocumentation

Clarabel.cpp is a C/C++ wrapper of Clarabel.rs.

Installation

Note: The C++ interface is WIP and there might be breaking changes in future releases.

Clarabel.cpp uses CMake to generate the build system and requires the following dependencies:

You may install Eigen via the system package manager on Unix-like systems or vcpkg on Windows.

Ubuntu:

sudo apt install libeigen3-dev

Windows:

vcpkg install eigen3:x64-windows

Clone this repo

git clone --recurse-submodules https://github.com/oxfordcontrol/Clarabel.cpp.git
cd Clarabel.cpp

Build

mkdir build
cd build
cmake ..
cmake --build .

You may specify a particular build system using the -G flag for cmake (e.g. -G "Unix Makefiles").

Windows

If you are using vcpkg on Windows, you may find the vcpkg toolchain file using:

vcpkg integrate install

and then specify the vcpkg toolchain file path and target triplet to generate the build system using:

cmake .. -DCMAKE_TOOLCHAIN_FILE=VCPKG_TOOLCHAIN_PATH -DVCPKG_TARGET_TRIPLET=x64-windows

where VCPKG_TOOLCHAIN_PATH is the path to the vcpkg toolchain file.

CMake options

SDP support

To enable SDP features, set the -DCLARABEL_FEATURE_SDP option to one of the following values:

By default, -DCLARABEL_FEATURE_SDP=none and SDP support is disabled.

JSON file input/output support

To enable reading and writing of problem data to JSON files, set -DCLARABEL_FEATURE_SERDE=true.

When reporting issues with the solver, it can be helpful to provide a JSON file that reproduces the problem.

Alternative linear algebra libraries

To enable the use of the faer-rs sparse linear algebra library as an additional solver option, set -DCLARABEL_FEATURE_FAER_SPARSE=true.

Unit tests

By default, unit tests are disabled to reduce build time. To enable unit tests, set -DCLARABEL_BUILD_TESTS=true in cmake.

Release mode

The solver will build the Rust source in debug mode. To build in release mode, set -DCMAKE_BUILD_TYPE=Release in cmake.

Run examples

Examples for both C and C++ are available in examples/c and examples/cpp and can be run from the build directory using:

./examples/c/C_EXAMPLE
./examples/cpp/CPP_EXAMPLE

Usage

License 🔍

This project is licensed under the Apache License 2.0 - see the LICENSE.md file for details.