Installation
This page will guide you through the process of installing Fatrop.
Binaries
Using Conda (Recommended)
Fatrop v0 binaries are available on conda.
Warning
Currently, only Fatrop v0 is available on conda. It is recommended to install the newest version from source for the latest improvements.
Fatrop is shipped by default with the conda CasADi package. To install, simply run:
conda install casadi
Alternatively, you can install the libfatrop package directly:
conda install libfatrop
Using PyPI (Not Recommended)
While it’s possible to install Fatrop v0 via PyPI, this method is not recommended as it currently doesn’t enable CPU-specific optimizations. This means that the performance of the PyPI binaries is significantly lower than the performance of the binaries installed via conda or from source.
Using Docker
A Dockerfile is available in the root directory of the repository. It can be built and run using the following commands, which should be sufficient to try out the Python examples:
docker build -t my-fatrop-image .
docker run -it --rm -v "$PWD":/workspace -w /workspace my-fatrop-image bash
Installation from Source
Dependencies
The only dependency of Fatrop is Blasfeo, a high-performance library for linear algebra operations.
To install Blasfeo from source:
Clone the Blasfeo repository:
git clone https://github.com/giaf/blasfeo.git cd blasfeo
Create a build directory and navigate into it:
mkdir build cd build
Configure the project with CMake, specifying the installation prefix:
cmake .. -DTARGET=<blasfeo target> -DCMAKE_INSTALL_PREFIX=</path/to/install/directory>
Here,
<blasfeo target>
should be replaced with the target CPU architecture you want to build for. A list of available targets can be found on the BLASFEO GitHub page.Note
You can use
$CONDA_PREFIX
as the installation directory if you’re using a Conda environment.Build the project:
make -j$(nproc)
Install Blasfeo:
make install
Fatrop
To install Fatrop from source:
Clone the Fatrop repository:
git clone https://github.com/meco-group/fatrop.git cd fatrop
Create a build directory and navigate into it:
mkdir build cd build
Configure the project with CMake, specifying the installation prefix:
cmake .. -DCMAKE_INSTALL_PREFIX=</path/to/install/directory>
Build the project:
make -j$(nproc)
Install Fatrop:
make install
This will install Fatrop to the directory specified by
CMAKE_INSTALL_PREFIX
.To verify that Fatrop has been installed correctly, you can run one of the example programs provided in the
examples
directory.
CasADi (Optional)
While not required for Fatrop itself, CasADi is often used alongside Fatrop for modeling and optimization. To install CasADi from source:
Clone the CasADi repository:
git clone https://github.com/casadi/casadi.git cd casadi
Create a build directory and navigate into it:
mkdir build cd build
Configure the project with CMake, specifying the desired options:
cmake .. \ -DWITH_IPOPT=ON -DWITH_BUILD_IPOPT=ON \ -DWITH_BUILD_MUMPS=ON -DWITH_BUILD_METIS=ON \ -DWITH_FATROP=ON \ -DWITH_PYTHON=ON -DWITH_PYTHON3=ON \ -DPYTHON_PREFIX=$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())') \ -DCMAKE_INSTALL_PREFIX=</path/to/install/directory> \ -DCMAKE_BUILD_TYPE=Release
Build the project:
make -j$(nproc)
Install CasADi:
make install