Pypopt: Ipopt for Python
Pypopt is an Ipopt wrapper for Python. The aim is to expose the same API as Ipopt C++ interface.
Examples
You can find examples in the examples/ folder.
PythonJournal
In Pypopt you can use Python objects as targets for Ipopt journaling. The Python objects needs to implement two methods:
write(str): called to write str to the stream object
flush(): called to flush the stream
This means we can use Python3 io.StringIO to capture Ipopt output to string:
app = IpoptApplication()
f = io.StringIO()
j = PythonJournal(EJournalLevel.J_NONE, f)
jnlst = app.journalist()
jnlst.add_journal(j)
Requirements
A working C++ compiler
Cython
Ipopt
Pytest + pytest-runner + pytest-cov for testing
Ipopt Installation
We recommend installing Ipopt from source.
If you have Ipopt installed in a different location than /usr set the following environment variables before proceeding to the next section:
IPOPT_INCLUDE_DIR=/path/to/ipopt/include IPOPT_LIBRARY_DIR=/path/to/ipopt/lib
Installation
Pypopt is available on Pypi:
pip install pypopt
Installation from Source
To install pypopt simply run:
python setup.py install
Troubleshooting
Pypopt is a Cython extension, this makes it sometimes tricky to install correctly.
Different toolchain for Ipopt and Pypopt
Ipopt and Pypopt need to be compiled with the same C++ toolchain. If that’s not the case, you will see an error like the following when loading Pypopt:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/lib/python3.6/site-packages/pypopt/__init__.py", line 24, in <module> from pypopt._cython import ( ImportError: /lib/python3.6/site-packages/pypopt/_cython.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN5Ipopt7Journal4NameB5cxx11Ev
This means Ipopt and Pypopt were compiled with different compilers/flags. To fix this issue install Ipopt from source and set the IPOPT_INCLUDE_DIR and IPOPT_LIBRARY_DIR environment variables to your Ipopt installation.
License
Copyright 2018 Francesco Ceccon
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Changelog
0.5.0 (2020-04-28)
Improve TNLP interface for optimal performance
Implement Pyomo direct solver interface
0.4.2 (2018-07-05)
Documentation update
0.4.1 (2018-07-05)
Fix MANIFEST.in
0.4.0 (2018-07-05)
Changes to TNLP interface
Metadata
Release files for pypopt 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pypopt-0.6.0.tar.gz | 205.9 kB | Without provenance | Details for pypopt-0.6.0.tar.gz |
Release files / pypopt-0.6.0.tar.gz
| Download URL | pypopt-0.6.0.tar.gz |
|---|---|
| Size | 205.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f199d01422c25dafc945460a1e9cbca4c100423d46216817c7bf3d4dd2f42ce
|
|
BLAKE2b-256 checksum How to use checksums |
12094a111d68c509e215f2872e09d6597ef285109eee1a12b1fbdb91647c36c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8
|
Security for pypopt 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.