{"id":19414438,"url":"https://github.com/ethz-adrl/ifopt","last_synced_at":"2025-05-15T00:12:25.059Z","repository":{"id":40990947,"uuid":"114131004","full_name":"ethz-adrl/ifopt","owner":"ethz-adrl","description":"An Eigen-based, light-weight C++ Interface to Nonlinear Programming Solvers (Ipopt, Snopt)","archived":false,"fork":false,"pushed_at":"2025-03-21T13:57:54.000Z","size":448,"stargazers_count":811,"open_issues_count":15,"forks_count":162,"subscribers_count":33,"default_branch":"master","last_synced_at":"2025-04-07T19:06:35.667Z","etag":null,"topics":["catkin","cmake","cpp","eigen","ipopt","mathematical-programming","nlp","nonlinear-optimization","optimization","robotics","ros","snopt","trajectory-optimization"],"latest_commit_sha":null,"homepage":"http://wiki.ros.org/ifopt","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ethz-adrl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.rst","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-12-13T14:30:12.000Z","updated_at":"2025-04-06T02:58:17.000Z","dependencies_parsed_at":"2023-01-21T13:45:49.377Z","dependency_job_id":null,"html_url":"https://github.com/ethz-adrl/ifopt","commit_stats":{"total_commits":200,"total_committers":18,"mean_commits":11.11111111111111,"dds":0.4,"last_synced_commit":"abcf7fc46aebf22941c56f2c285b6748764cb5de"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethz-adrl%2Fifopt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethz-adrl%2Fifopt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethz-adrl%2Fifopt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethz-adrl%2Fifopt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethz-adrl","download_url":"https://codeload.github.com/ethz-adrl/ifopt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248968915,"owners_count":21191162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["catkin","cmake","cpp","eigen","ipopt","mathematical-programming","nlp","nonlinear-optimization","optimization","robotics","ros","snopt","trajectory-optimization"],"created_at":"2024-11-10T12:38:07.453Z","updated_at":"2025-04-14T22:11:50.683Z","avatar_url":"https://github.com/ethz-adrl.png","language":"C++","readme":"### \u003cimg src=\"https://i.imgur.com/ZOfGZwB.png\" height=\"60\" /\u003e\n\n[![Build Status](http://build.ros.org/buildStatus/icon?job=Kdev__ifopt__ubuntu_xenial_amd64)](http://build.ros.org/view/Kdev/job/Kdev__ifopt__ubuntu_xenial_amd64/)\n[![Documentation](https://img.shields.io/badge/docs-generated-brightgreen.svg)](http://docs.ros.org/api/ifopt/html/)\n[![ROS integration](https://img.shields.io/badge/ROS-integration-blue.svg)](http://wiki.ros.org/ifopt)\n![](https://tokei.rs/b1/github/ethz-adrl/ifopt?category=code)\n[![CodeFactor](https://www.codefactor.io/repository/github/ethz-adrl/ifopt/badge)](https://www.codefactor.io/repository/github/ethz-adrl/ifopt)\n[![License BSD-3-Clause](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)](https://tldrlegal.com/license/bsd-3-clause-license-%28revised%29#fulltext)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1135046.svg)](https://doi.org/10.5281/zenodo.1135046)\n\u003c!-- The actual jenkins documentation job can be found here --\u003e\n\u003c!-- http://build.ros.org/view/Ldoc/job/Ldoc__ifopt__ubuntu_xenial_amd64/ --\u003e\n\n*A modern, light-weight, [Eigen]-based C++ interface to Nonlinear Programming solvers, such as [Ipopt] and [Snopt].*\n\nAn example nonlinear optimization problem to solve is defined as:\n\n\u003cimg align=\"center\" height=\"100\" src=\"https://i.imgur.com/YGi4LrR.png\"/\u003e\n\n* To see how this problem is formulated, see [*test_vars_constr_cost.h*](ifopt_core/test/ifopt/test_vars_constr_cost.h).   \n* Afterwards the problem can be solved using e.g. Ipopt as shown in [*ex_test_ipopt.cc*](ifopt_ipopt/test/ex_test_ipopt.cc).\n\n\u003c/br\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#features\"\u003eFeatures\u003c/a\u003e •\n  \u003ca href=\"#install\"\u003eInstall\u003c/a\u003e •\n  \u003ca href=\"#examples\"\u003eExamples\u003c/a\u003e •\n  \u003ca href=\"#contribute\"\u003eContribute\u003c/a\u003e •\n  \u003ca href=\"#publications\"\u003ePublications\u003c/a\u003e •\n  \u003ca href=\"#authors\"\u003eAuthors\u003c/a\u003e\n\u003c/p\u003e\n\n## Features\n*Combines* the advantages of [Ipopt] / [Snopt] and [Eigen]:\n\n[Ipopt] / [Snopt]  | [Eigen] \n----------|---------\n:heavy_check_mark: high-quality solvers for nonlinear optimization  | :heavy_check_mark: modern, intuitive formulations of vectors and matrices \n:x: C++ API inconvenient and error-prone (raw pointers, index management, jacobian construction) | :heavy_check_mark: highly efficient implementations   \n:x: linking and exporting difficult  | \n\n* Solver independent formulation of variables and constraints with Eigen (highly efficient)     \n* Automatic index management by formulation of [variable- and constraint-sets](http://docs.ros.org/api/ifopt/html/group__ProblemFormulation.html)  \n* Integration: pure cmake `find_package(ifopt)` or [catkin]/[ROS] (optional)       \n* light-weight (~[2k lines of code](https://i.imgur.com/NCPJsSw.png)) makes it easy to use and extend    \n\n\u003c/br\u003e\n\nAn optimization problem consists of multiple *independent variable- and constraint-sets*. Each set represents a common concept, e.g. a set of variables might represents spline coefficients, another footstep positions. Similarly, a constraint-set groups similar constraints together.  `ifopt` allows users to define each of these sets independently in separate classes and then builds the overall problem from these sets. (No more worrying adapting indices when adding or removing sets).\n\n\u003c/br\u003e\n\n```\nfind x0, x1                              (variable-sets 0 \u0026 1)\ns.t\n  x0_lower  \u003c= x0 \u003c= x0_upper            (bounds on variable-set x0 \\in R^2)\n\n  {x0,x1} = arg min c0(x0,x1)+c1(x0,x1)  (cost-terms 0 and 1)\n\n  g0_lower \u003c g0(x0,x1) \u003c g0_upper        (constraint-set 0 \\in R^2)\n  g1_lower \u003c g1(x0,x1) \u003c g0_upper        (constraint-set 1 \\in R^1)\n```\n\n\u003c/br\u003e\n\nSupplying derivative information greatly increases solution speed. `ifopt` allows to define the derivative of each cost-term/constraint-set with respect to each variable-set *independently*. This ensures that when the order of variable-sets changes in the overall vector, this derivative information is still valid. These \"Jacobian blocks\" must be supplied through ``ConstraintSet::FillJacobianBlock()`` and are then used to build the complete Jacobian for the cost and constraints.\n\n\u003c/br\u003e\n\n\u003cimg src=\"http://docs.ros.org/api/ifopt/html/ifopt.png\" height=\"400\" /\u003e\n\n\n A graphical overview as UML can be seen [here](http://docs.ros.org/api/ifopt/html/inherits.html).\n\n\n\n## Install\nThe easiest way to install is through the [ROS binaries](http://wiki.ros.org/ifopt) and you're all set!\n```\nsudo apt-get install ros-\u003cdistro\u003e-ifopt\n```\n\n#### Install dependencies\nIn case you don't use ROS or the binaries don't exist for your distro, you can easily build these\npackages from source. For this, install the required dependencies [Cmake], [Eigen] and [Ipopt] using\n```\nsudo apt-get install cmake libeigen3-dev coinor-libipopt-dev\n```\nIf you want to link to a local installation of [Ipopt] or to [Snopt], see [here](#additional-information).\n\n#### Build with cmake\n* Install\n  ```bash\n  git clone https://github.com/ethz-adrl/ifopt.git \u0026\u0026 cd ifopt\n  mkdir build \u0026\u0026 cd build\n  cmake ..\n  make\n  sudo make install # copies files in this folder to /usr/local/*\n  # sudo xargs rm \u003c install_manifest.txt # in case you want to uninstall the above\n  ```\n\n* Use: To use in your cmake project, see this minimal *CMakeLists.txt*:\n  ```cmake\n  find_package(ifopt)\n  # Formulate (ifopt:ifopt_core) and solve (ifopt::ifopt_ipopt) the problem\n  add_executable(main main.cpp)\n  # Pull in include directories, libraries, ... \n  target_link_libraries(main PUBLIC ifopt::ifopt_ipopt) \n  ```\n        \n#### Build with catkin\n* Install: Download [catkin] or [catkin command line tools], then:\n  ```bash\n  cd catkin_ws/src\n  git clone https://github.com/ethz-adrl/ifopt.git\n  cd ..\n  catkin_make_isolated # `catkin build` if you are using catkin command-line tools \n  source ./devel/setup.bash\n  ```\n  \n* Use: Include in your catkin project by adding to your *CMakeLists.txt* \n  ```cmake\n  add_compile_options(-std=c++11)\n  find_package(catkin COMPONENTS ifopt) \n  include_directories(${catkin_INCLUDE_DIRS})\n  target_link_libraries(foo ${catkin_LIBRARIES})\n  ```\n  Add the following to your *package.xml*:\n  ```xml\n  \u003cpackage\u003e\n    \u003cdepend\u003eifopt\u003c/depend\u003e\n  \u003c/package\u003e\n  ```\n  \n## Examples \n#### Unit tests \u0026 toy problem\nNavigate to your build folder in which the `Makefile` resides, which depends\non how you built the code:\n```bash\ncd ifopt/build  # plain cmake \ncd catkin_ws/build_isolated/ifopt/devel # catkin_make_isolated\ncd catkin_ws/build/ifopt # catkin build\n```\nMake sure everything installed correctly by running the `test` target\n```bash\nmake test\n```\nYou should see `ifopt_ipopt-example....Passed` (or snopt if installed) as well as `ifopt_core-test` if\n[gtest] is installed.\n\nIf you have IPOPT installed and linked correctly, you can also run the [binary example](ifopt_ipopt/test/ex_test_ipopt.cc) \ndirectly (again, first navigate to the build folder with the `Makefile`)\n```bash\nmake test ARGS='-R ifopt_ipopt-example -V'\n```\nOutput:\n```bash\n1.0 0.0\n```\n\n#### towr\nA more involved problem, taken from [towr], with multiple sets of variables and constraints to generate motions for legged robots produces the following: \n\n\u003cimg align=\"center\" height=\"500\" src=\"https://i.imgur.com/4yhohZF.png\"/\u003e\n\n## Contribute\nWe love pull request, whether its interfaces to additional solvers, bug fixes, unit tests or updating the documentation. Please have a look at [CONTRIBUTING.md](CONTRIBUTING.md) for more information. \nSee here the list of [contributors](https://github.com/ethz-adrl/ifopt/graphs/contributors) who participated in this project.\n\n\n## Publications\nIf you use this work, please consider citing as follows:\n\n    @misc{ifopt,\n      author       = {Alexander W Winkler},\n      title        = {{Ifopt - A modern, light-weight, Eigen-based C++ interface to \n                       Nonlinear Programming solvers Ipopt and Snopt.}},\n      year         = 2018,\n      doi          = {10.5281/zenodo.1135046},\n      url          = {https://doi.org/10.5281/zenodo.1135046}\n    }\n\nThe research project within which this code was developed:\n* A. W. Winkler, D. Bellicoso, M. Hutter, J. Buchli, [Gait and Trajectory Optimization for Legged Systems through Phase-based End-Effector Parameterization](http://awinkler.me), IEEE Robotics and Automation Letters (RA-L), 2018:\n\n\n## Authors \n[Alexander W. Winkler](https://www.alex-winkler.com) - Initial Work/Maintainer\n\nThis was has been carried out at the following institutions:\n\n[\u003cimg src=\"https://i.imgur.com/aGOnNTZ.png\" height=\"45\" /\u003e](https://www.ethz.ch/en.html \"ETH Zurich\") \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; [\u003cimg src=\"https://i.imgur.com/uCvLs2j.png\" height=\"45\" /\u003e](http://www.adrl.ethz.ch/doku.php \"Agile and Dexterous Robotics Lab\")  \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;[\u003cimg src=\"https://i.imgur.com/gYxWH9p.png\" height=\"45\" /\u003e](http://www.rsl.ethz.ch/ \"Robotic Systems Lab\")\n\n\n\n## Additional Information\n#### Linking to custom Ipopt or Snopt\nIf you are building from source and want to use a locally installed version of [Ipopt] add the path to your\nIpopt build folder to your `~/.bashrc`, e.g.\n```bash\nexport IPOPT_DIR=/home/your_name/Code/Ipopt-3.12.8/build\n```\n\nIn case your OS doesn't provide the precompiled binaries or the required version,\nyou can also easily install Ipopt from source as described [here](https://www.coin-or.org/Ipopt/documentation/node14.html). This summary might work for you:\n```bash\nwget https://www.coin-or.org/download/source/Ipopt/Ipopt-3.11.10.zip\nunzip Ipopt-3.11.10.zip\ncd Ipopt-3.11.10/ThirdParty/Mumps\n./get.Mumps  # HSL routines are faster (http://www.hsl.rl.ac.uk/ipopt/)\ncd ../../\nmkdir build \u0026\u0026 cd build\n../configure --prefix=/usr/local\nmake\nmake test\nmake install\nexport IPOPT_DIR=`pwd`\n```\n\nIf you need an interface to [Snopt], point cmake to that build folder in your `~/.bashrc` through e.g.\n```bash\nexport SNOPT_DIR=/home/your_name/Code/Snopt\n```\nand run cmake as \n```bash\ncmake -DBUILD_SNOPT=ON ..\n```\n\n\n[CMake]: https://cmake.org/cmake/help/v3.0/\n[Eigen]: http://eigen.tuxfamily.org\n[Ipopt]: https://projects.coin-or.org/Ipopt\n[Snopt]: http://ampl.com/products/solvers/solvers-we-sell/snopt/\n[catkin]: http://wiki.ros.org/catkin/Tutorials/create_a_workspace\n[catkin command line tools]: http://catkin-tools.readthedocs.io/en/latest/installing.html\n[towr]: https://github.com/ethz-adrl/towr\n[catkin tools]: http://catkin-tools.readthedocs.org/\n[ROS]: http://www.ros.org\n[rviz]: http://wiki.ros.org/rviz\n[gtest]: https://github.com/google/googletest\n\n\n","funding_links":[],"categories":["8. Tutorials","[Libraries](#awesome-robotics-libraries)"],"sub_categories":["8.4 Optimization Techniques","[Optimization](#awesome-robotics-libraries)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethz-adrl%2Fifopt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethz-adrl%2Fifopt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethz-adrl%2Fifopt/lists"}