Installation

This page will guide you through the process of installing Fatrop.

Binaries

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:

  1. Clone the Blasfeo repository:

    git clone https://github.com/giaf/blasfeo.git
    cd blasfeo
    
  2. Create a build directory and navigate into it:

    mkdir build
    cd build
    
  3. 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.

  4. Build the project:

    make -j$(nproc)
    
  5. Install Blasfeo:

    make install
    

Fatrop

To install Fatrop from source:

  1. Clone the Fatrop repository:

    git clone https://github.com/meco-group/fatrop.git
    cd fatrop
    
  2. Create a build directory and navigate into it:

    mkdir build
    cd build
    
  3. Configure the project with CMake, specifying the installation prefix:

    cmake .. -DCMAKE_INSTALL_PREFIX=</path/to/install/directory>
    
  4. Build the project:

    make -j$(nproc)
    
  5. 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:

  1. Clone the CasADi repository:

    git clone https://github.com/casadi/casadi.git
    cd casadi
    
  2. Create a build directory and navigate into it:

    mkdir build
    cd build
    
  3. 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
    
  4. Build the project:

    make -j$(nproc)
    
  5. Install CasADi:

    make install