Skip to main content

pipeline status python version latest version Checked with mypy Ruff DOI

ipyopt is a Python 🐍 C++ extension that allows you to use Ipopt in Python.

Install • Usage • Docs

ipyopt

Ipopt solves general nonlinear programming problems of the form

min f(x)

under the constraints

g_l <= g(x) <= g_u,
x_l <= x <= x_u,

where x is n dimensional and g(x) is m dimensional.

Goal

Provide as much performance as possible. This is also reflected in the fact that the shipped scipy.optimize.minimize ipopt method deviates in some concerns from the usual methods in scipy. If you are interested in a more scipy like interface, have a look at cyipopt.

Installation

Note the pypi repository currently only provides 🐧 linux wheels.

pip install [--user] ipyopt

This will install a precompiled binary version from pypi. Please note, that the precompiled binary is linked against the unoptimized reference implementation of blas/lapack. If you want to take advantage of optimized versions of blas/lapack, compile from source:

pip install --no-binary ipyopt ipyopt

In this case, you also need Ipopt and Numpy. On a debian based system:

sudo apt-get install python3-numpy coinor-ipopt

If coinor-ipopt does not link correctly, you might have to compile ipopt yourself. See the section Build below or .ci/Dockerfile on how this can be done.

Usage

You can use ipyopt like this:

import ipyopt
# define your call back functions
nlp = ipyopt.Problem(...)
nlp.solve(...)

For an example, see examples/hs071.py.

Note that the ipyopt.Problem.solve(.) mutates some its arguments, including the initial guess for the variables, and the multipliers.

For maximal performance, there is also support for PyCapsules / scipy.LowLevelCallable. By using this approach, there will be no C++ <-> Python interactions during Ipopt optimization. Here is an example test/c_capsules/ (C code) and test/test_ipyopt.py (Python code using the PyCapsules provided by the C code).

For more details and hints, see the docs.

Build

ipyopt depends on the following packages:

  1. A compiler and a linker, e.g. gcc, ld
  2. Ipopt
  3. Numpy
  4. Python.h (part of the python source code, you can download it from Python.org)

To build from source, first, get the latest source code using:

git clone https://gitlab.com/ipyopt-devs/ipyopt.git

Check whether a file ipopt.pc was distributed with your Ipopt installation. If this is the case and ipopt.pc is in the search path of pkg-config (on unix systems: /usr/lib/pkgconfig, /usr/share/pkgconfig, /usr/local/lib/pkgconfig, /usr/local/share/pkgconfig), nothing has to be modified.

In this case run

python setup.py build
sudo python setup.py install

If pkg-config is not available for your system, you will need to pass appropriate information to setup.py by setting the environment variable CFLAGS. Example:

CFLAGS="-I/usr/include/coin/ -l/usr/lib64 -lipopt -lmumps_common -ldmumps -lzmumps -lsmumps -lcmumps -llapack -lblas -lblas -lblas -lm  -ldl' ./setup.py build
sudo python setup.py install

If you have an ipopt.pc which is not in the pkg-config search path, specify the path via the PKG_CONFIG_PATH environment variable (see below). If you cannot find an ipopt.pc in your ipopt installation, there is an example pc file pkgconfig/ipopt.pc. Copy it to a location (best of all directly in a subfolder named pkgconfig of your Ipopt installation) and edit it to reflect the library and include paths of the dependencies.

Then do

PKG_CONFIG_PATH=<dir containing ipopt.pc> python setup.py build
sudo python setup.py install

Testing

Unit tests:

python -m unittest

Run examples:

Use the following command under the examples directory.

python hs071.py

The file examples/hs071.py contains a toy optimization problem. If everything is OK, ipyopt will invoke Ipopt to solve it for you. This python file is self-documented and can be used as a template for writing your own optimization problems.

Hessian Estimation: since Hessian estimation is usually tedious, Ipopt can solve problems without Hessian estimation. ipyopt also supports this feature. The file examples/hs071.py demonstrates the idea. If you provide the ipyopt.Problem constructor with an eval_h callback function, Ipopt will delegate the Hessian matrix calculation to your function (otherwise Ipopt will approximate Hessian for you).

Contributing

  1. Fork it.
  2. Create a branch (git checkout -b new_branch)
  3. Commit your changes (git commit -am "your awesome message")
  4. Push to the branch (git push origin new_branch)
  5. Create a merge request

Credits

  • Modifications on logger made by OpenMDAO at NASA Glenn Research Center, 2010 and 2011
  • Added "eval_intermediate_callback" by OpenMDAO at NASA Glenn Research Center, 2010 and 2011
  • Modifications on the SAFE_FREE macro made by Guillaume Jacquenot, 2012
  • Changed logger from code contributed by alanfalloon
  • Originally developed by Eric Xu when he was a PhD student at Washington University and issued under the BSD license. Original repository: xuy/pyipopt.

Metadata

Release files for ipyopt 0.12.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ipyopt 0.12.10
File Size Uploaded
ipyopt-0.12.10.tar.gz 40.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for ipyopt 0.12.10
File
ipyopt-0.12.10-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 free-threading Linux glibc 2.17+ x86-64 Details
ipyopt-0.12.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
ipyopt-0.12.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
ipyopt-0.12.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
ipyopt-0.12.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
ipyopt-0.12.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
ipyopt-0.12.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
ipyopt-0.12.10-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details
ipyopt-0.12.10-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64 Details

Total release size: 118.5 MB

Release files / ipyopt-0.12.10.tar.gz

Download URL ipyopt-0.12.10.tar.gz
Size 40.5 kB
Tags Source
SHA-256 checksum
How to use checksums
223afd604f643568d9865cd660624017a2d9a5079b7040403f660f3b359cb71e
BLAKE2b-256 checksum
How to use checksums
f4338ed1fe07bde533af36c30688c1db022c2f82e6f98b27dda9f1c8b06eeae3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / ipyopt-0.12.10-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ipyopt-0.12.10-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 13.2 MB
Tags CPython 3.13 CPython 3.13 free-threading Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
43796deabcbb1dbda92ca725b98edd7d3929437e60da9a631b2759994a984445
BLAKE2b-256 checksum
How to use checksums
147c9b4739ebcd34bfab4d13499387399f249bcbf76e7f2e96db2e69f06e63d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / ipyopt-0.12.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ipyopt-0.12.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 13.2 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
bc20d1ad55c2bd9b56d05e9133f26344f1f1be2d5fce153f9859274bf3201c21
BLAKE2b-256 checksum
How to use checksums
83ecbd446bdff89aaf4f7a2e8d77d269ad0cccf159d23c12d3e9ab94cfebe11d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / ipyopt-0.12.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ipyopt-0.12.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 13.2 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
231887545247678965e8edf1bd4f0bda4fdc50b22dac7b0f1e56ffd2a0eac618
BLAKE2b-256 checksum
How to use checksums
367399b31dd2f3e08fcb3dc640dd03ceec5611548708b1926b97a5fa93ec7b2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / ipyopt-0.12.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ipyopt-0.12.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 13.2 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
38fe8560ac2b9cc14dba7ccc6194b146d7633cdeb33a3df683ca21d6f108eba4
BLAKE2b-256 checksum
How to use checksums
44acccb6893c4ec68bbd37186fc08ed726528b92ef11677aee26de4c4370b2e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / ipyopt-0.12.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ipyopt-0.12.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 13.2 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3d6eddf6964981214bb656ba1dc817dade925f0d7b02d89884694bac2e6e6cc9
BLAKE2b-256 checksum
How to use checksums
c40d16037e8c4d32a2e3d56507b30cf21c4cb0033da718f98162856126f6d9ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / ipyopt-0.12.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ipyopt-0.12.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 13.2 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
7e9aaf8afaa7a57ba743fb5d21047baa2d735339def2afea5429635579f12002
BLAKE2b-256 checksum
How to use checksums
9f9ad412de7833eb16d93974cc33f6886059c3b207ddd773d09ef1fa064cfad4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / ipyopt-0.12.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ipyopt-0.12.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 13.2 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e5dce48afdbcf1efdfed16d0e0406186333bcb487f546173254edd58f45e76aa
BLAKE2b-256 checksum
How to use checksums
35d1b2122ced1b8d4e3a11a49c77b6ea330005ce14f3f781ea327e2fff5077c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / ipyopt-0.12.10-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ipyopt-0.12.10-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 13.2 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
bfeb341c949510be81fa6c9feb347f8024aeb63624c0ada8e1d38909fe8e9611
BLAKE2b-256 checksum
How to use checksums
a2dd7b9876b21eb2ed17e8c56d9e5eb76f082240a1e0b0f72790508ae4d63d60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / ipyopt-0.12.10-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ipyopt-0.12.10-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 13.1 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
b45a3319091ef31b89b18d9e04501c460d838691388e14983778e8b05e439fcf
BLAKE2b-256 checksum
How to use checksums
b03756581c097c3d3476452100af8d0d2c1cd2e51b58a612843e385cbbb40c9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.12.10 This release

10 release files

0.12.9

8 release files

0.12.8

8 release files

0.12.6

7 release files

0.12.5

7 release files

0.12.3

5 release files

0.12.2

6 release files

0.12.1

6 release files

0.10.1

6 release files

0.9.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page