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:
- To see how this problem is formulated, see test_vars_constr_cost.h.
- Afterwards the problem can be solved using e.g. Ipopt as shown in ex_test_ipopt.cc.
Related variables and constraints are implemented (grouped) in independent sets. Ifopt automatically generates the overall problem from these sets. No more changing indices in your variable vector or Jacobian when adding or removing variables/constraints. See this large problem, that requires multiple variable- and constraint sets to generate the motion for legged robot (implemented in towr).
More Features:
✔️ Eigen allows inuitive formulation and fast performance due to sparse matrix exploitation.
✔️ exports cmake scripts to easily find_package(ifopt)
in your project.
✔️ catkin integration (optional).
✔️ light-weight (~2k lines of code) makes it easy to use and extend.
Name | Min. Ver. | Description | Install |
---|---|---|---|
CMake | v3.1.0 | C++ build tool | sudo apt-get install cmake (upgrade) |
Eigen | v3.2.0 | Library for linear algebra | sudo apt-get install libeigen3-dev |
Ipopt | v3.11.9 | NLP solver (Interior-Point) | sudo apt-get install coinor-libipopt-dev |
(Snopt) | 7.4 | NLP solver (SQP) | non-free |
Quick Install:
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 the doxygen documentation.
-
Install
git clone https://github.com/ethz-adrl/ifopt.git && cd ifopt mkdir build && cd build cmake .. make 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:
find_package(ifopt) # 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)
-
Install: Download catkin or catkin command line tools, then:
cd catkin_ws/src git clone https://github.com/ethz-adrl/ifopt.git 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) include_directories(${catkin_INCLUDE_DIRS}) target_link_libraries(foo ${catkin_LIBRARIES})
Add the following to your package.xml:
<package> <depend>ifopt</depend> </package>
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'
Output:
1.0 0.0
Each set of variables, costs and constraints are formulated by one C++ object purely through Eigen vectors and matrices and independent from any specific solver. Although the above example adds just one, multiple sets of variables or constraints can be added to the NLP and ifopt manages the overall variable vector and jacobian, so each set can be implemented independent of the others. A more involved problem definition with multiple sets of variables and constraints, taken from towr can be seen in the following:
Alexander W. Winkler - Initial Work/Maintainer
This was has been carried out at the following institutions:
If you use this work in an academic context, please consider citing the currently released version as shown here or the research project within which this code was developed:
A. W. Winkler, D. Bellicoso, M. Hutter, J. Buchli, Gait and Trajectory Optimization for Legged Systems through Phase-based End-Effector Parameterization, IEEE Robotics and Automation Letters (RA-L), 2018:
@article{winkler18,
author = {Winkler, Alexander W and Bellicoso, Dario C and
Hutter, Marco and Buchli, Jonas},
title = {Gait and Trajectory Optimization for Legged Systems
through Phase-based End-Effector Parameterization},
journal = {IEEE Robotics and Automation Letters (RA-L)},
year = {2018},
month = {July},
pages = {1560-1567},
volume = {3},
doi = {10.1109/LRA.2018.2798285},
}
We love pull request, whether its interfaces to additional solvers, bug fixes, unit tests or updating the documentation. Please have a look at CONTRIBUTING.md for more information. See here the list of contributors who participated in this project.
To report bugs, request features or ask questions, please have a look at CONTRIBUTING.md.