Skip to content
An Eigen-based, light-weight C++ Interface to Nonlinear Programming Solvers (Ipopt, Snopt)
Branch: master
Clone or download
Latest commit 8cc9168 Jan 29, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc Improve documentation (#28) Jul 26, 2018
ifopt_ipopt Fix/segfaults (#33) Oct 15, 2018
ifopt_snopt Improve documentation (#28) Jul 26, 2018
.gitignore Improve doxygen (#22) Jul 12, 2018
CMakeLists.txt update changelog Jan 17, 2019 Create Jul 10, 2018
LICENSE update license Jan 29, 2018 Update Jan 29, 2019

Build Status Documentation ROS integration CodeFactor License BSD-3-Clause DOI

A modern, light-weight, Eigen-based C++ interface to Nonlinear Programming solvers, such as Ipopt and Snopt.

An example nonlinear optimization problem to solve is defined as:



Combines the advantages of Ipopt / Snopt and Eigen:

Ipopt / Snopt Eigen
✔️ high-quality solvers for nonlinear optimization ✔️ modern, intuitive formulations of vectors and matrices
C++ API inconvenient and error-prone (raw pointers, index management, jacobian construction) ✔️ highly efficient implementations
linking and exporting difficult
  • Solver independent formulation of variables and constraints with Eigen (highly efficient)
  • Automatic index management by formulation of variable- and constraint-sets
  • Integration: pure cmake find_package(ifopt) or catkin/ROS (optional)
  • light-weight (~2k lines of code) makes it easy to use and extend


The easiest way to install is through the ROS binaries and you're all set!

sudo apt-get install ros-<distro>-ifopt

Install dependencies

In case you don't use ROS or the binaries don't exist for your distro, you can easily build these packages from source. For this, install the required dependencies Cmake, Eigen and Ipopt using

sudo apt-get install cmake libeigen3-dev coinor-libipopt-dev

If you want to link to a local installation of Ipopt or to Snopt, see here.

Build with cmake

  • Install

    git clone && cd ifopt
    mkdir build && cd build
    cmake ..
    sudo make install # copies files in this folder to /usr/local/*
    # sudo xargs rm < install_manifest.txt # in case you want to uninstall the above
  • Use: To use in your cmake project, see this minimal CMakeLists.txt:

    # Formulate (ifopt:ifopt_core) and solve (ifopt::ifopt_ipopt) the problem
    add_executable(main main.cpp)
    # Pull in include directories, libraries, ... 
    target_link_libraries(main PUBLIC ifopt::ifopt_ipopt) 

Build with catkin

  • Install: Download catkin or catkin command line tools, then:

    cd catkin_ws/src
    git clone
    cd ..
    catkin_make_isolated # `catkin build` if you are using catkin command-line tools 
    source ./devel/setup.bash
  • Use: Include in your catkin project by adding to your CMakeLists.txt

    find_package(catkin COMPONENTS ifopt) 
    target_link_libraries(foo ${catkin_LIBRARIES})

    Add the following to your package.xml:



Unit tests & toy problem

Navigate to your build folder in which the Makefile resides, which depends on how you built the code:

cd ifopt/build  # plain cmake 
cd catkin_ws/build_isolated/ifopt/devel # catkin_make_isolated
cd catkin_ws/build/ifopt # catkin build

Make sure everything installed correctly by running the test target

make test

You should see ifopt_ipopt-example....Passed (or snopt if installed) as well as ifopt_core-test if gtest is installed.

If you have IPOPT installed and linked correctly, you can also run the binary example directly (again, first navigate to the build folder with the Makefile)

make test ARGS='-R ifopt_ipopt-example -V'


1.0 0.0


A more involved problem, taken from towr, with multiple sets of variables and constraints to generate motions for legged robots produces the following:


Useful information for developers is given in the doxygen documentation:

  • For an overview of how to formulate your problem, start here.
  • A nice graphical overview as UML can be seen here.


We love pull request, whether its interfaces to additional solvers, bug fixes, unit tests or updating the documentation. Please have a look at for more information. See here the list of contributors who participated in this project.


If you use this work, please consider citing as follows:

  author       = {Alexander W Winkler},
  title        = {{Ifopt - A modern, light-weight, Eigen-based C++ interface to 
                   Nonlinear Programming solvers Ipopt and Snopt.}},
  year         = 2018,
  doi          = {10.5281/zenodo.1135046},
  url          = {}

The research project within which this code was developed:


Alexander W. Winkler - Initial Work/Maintainer

This was has been carried out at the following institutions:


Additional Information

Linking to custom Ipopt or Snopt

If you are building from source and want to use a locally installed version of Ipopt add the path to your Ipopt build folder to your ~/.bashrc, e.g.

export IPOPT_DIR=/home/your_name/Code/Ipopt-3.12.8/build

In case your OS doesn't provide the precompiled binaries or the required version, you can also easily install Ipopt from source as described here. This summary might work for you:

cd Ipopt-3.11.10/ThirdParty/Mumps
./get.Mumps  # HSL routines are faster (
cd ../../
mkdir build && cd build
../configure --prefix=/usr/local
make test
make install
export IPOPT_DIR=`pwd`

If you need an interface to Snopt, point cmake to that build folder in your ~/.bashrc through e.g.

export SNOPT_DIR=/home/your_name/Code/Snopt

and run cmake as

You can’t perform that action at this time.