Skip to main content

Python interface to multiple optimization solvers

Project description

PyOptInterface (Python Optimization Interface)

PyOptInterface is an open-source Python library to provide a unified API to construct and solve optimization models with various optimizers.

The detailed documentation can be found here.

Key features compared with other modeling interfaces

It is designed as a very thin wrapper of native C API of optimizers and attempts to provide common abstractions of an algebraic modelling environment including model, variable, constraint and expression with the least overhead of performance.

The key features of PyOptInterface include:

  • Very fast speed to construct optimization model (10x faster than Pyomo, comparable with JuMP.jl and some official Python bindings provided by vendors of optimizer)
  • Low overhead to modify and re-solve the problem incrementally (including adding/removing variables/constraints, changing objective function, etc.)
  • Unified API to cover common usages, write once and the code works for all optimizers
  • You still have escape hatch to query or modify solver-specific parameter/attribute/information for different optimizers directly like the vendor-specific Python binding of optimizer

Benchmark

The benchmark comparing PyOptInterface with some other modeling interfaces can be found here. PyOptInterface is among the fastest modeling interfaces in terms of model construction time.

Installation

PyOptInterface is available on PyPI. You can install it via pip:

pip install pyoptinterface

After installation, you can import the package in Python console:

import pyoptinterface as poi

PyOptInterface has no dependencies other than Python itself. However, to use it with a specific optimizer, you need to install the corresponding optimizer manually. The details can be found on the configurations of optimizers.

In order to provide out-of-the-box support for open source optimizers (currently we support HiGHS), PyOptInterface can also be installed with pre-built optimizers. You can install them via pip:

pip install pyoptinterface[highs]

It will install a full-featured binary version of HiGHS optimizer via highsbox, which can be used with PyOptInterface.

What kind of problems can PyOptInterface solve?

It currently supports the following problem types:

  • Linear Programming (LP)
  • Mixed-Integer Linear Programming (MILP)
  • Quadratic Programming (QP)
  • Mixed-Integer Quadratic Programming (MIQP)
  • Quadratically Constrained Quadratic Programming (QCQP)
  • Mixed-Integer Quadratically Constrained Quadratic Programming (MIQCQP)
  • Second-Order Cone Programming (SOCP)
  • Mixed-Integer Second-Order Cone Programming (MISOCP)

What optimizers does PyOptInterface support?

It currently supports the following optimizers:

Short Example

import pyoptinterface as poi
from pyoptinterface import highs

model = highs.Model()

x = model.add_variable(lb=0, ub=1, domain=poi.VariableDomain.Continuous, name="x")
y = model.add_variable(lb=0, ub=1, domain=poi.VariableDomain.Integer, name="y")

con = model.add_linear_constraint(x+y, poi.Geq, 1.2, name="con")

obj = 2*x
model.set_objective(obj, poi.ObjectiveSense.Minimize)

model.set_model_attribute(poi.ModelAttribute.Silent, False)
model.optimize()

print(model.get_model_attribute(poi.ModelAttribute.TerminationStatus))
# TerminationStatusCode.OPTIMAL

x_val = model.get_value(x)
# 0.2

y_val = model.get_value(y)
# 1.0

License

PyOptInterface is licensed under MPL-2.0 License.

It uses nanobind, fmtlib and martinus/unordered_dense as dependencies.

The design of PyOptInterface is inspired by JuMP.jl.

Some solver-related code in src folder is adapted from the corresponding solver interface package in JuMP.jl ecosystem, which is licensed under MIT License.

The header files in thirdparty/solvers directory are from the corresponding distribution of optimizers and are licensed under their own licenses.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pyoptinterface-0.2.1-cp312-cp312-win_amd64.whl (657.9 kB view details)

Uploaded CPython 3.12 Windows x86-64

pyoptinterface-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyoptinterface-0.2.1-cp312-cp312-macosx_11_0_arm64.whl (728.5 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

pyoptinterface-0.2.1-cp312-cp312-macosx_10_14_x86_64.whl (801.8 kB view details)

Uploaded CPython 3.12 macOS 10.14+ x86-64

pyoptinterface-0.2.1-cp311-cp311-win_amd64.whl (670.3 kB view details)

Uploaded CPython 3.11 Windows x86-64

pyoptinterface-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyoptinterface-0.2.1-cp311-cp311-macosx_11_0_arm64.whl (738.8 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pyoptinterface-0.2.1-cp311-cp311-macosx_10_14_x86_64.whl (813.9 kB view details)

Uploaded CPython 3.11 macOS 10.14+ x86-64

pyoptinterface-0.2.1-cp310-cp310-win_amd64.whl (671.1 kB view details)

Uploaded CPython 3.10 Windows x86-64

pyoptinterface-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyoptinterface-0.2.1-cp310-cp310-macosx_11_0_arm64.whl (739.6 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pyoptinterface-0.2.1-cp310-cp310-macosx_10_14_x86_64.whl (814.6 kB view details)

Uploaded CPython 3.10 macOS 10.14+ x86-64

pyoptinterface-0.2.1-cp39-cp39-win_amd64.whl (672.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

pyoptinterface-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyoptinterface-0.2.1-cp39-cp39-macosx_11_0_arm64.whl (740.2 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pyoptinterface-0.2.1-cp39-cp39-macosx_10_14_x86_64.whl (815.4 kB view details)

Uploaded CPython 3.9 macOS 10.14+ x86-64

pyoptinterface-0.2.1-cp38-cp38-win_amd64.whl (673.1 kB view details)

Uploaded CPython 3.8 Windows x86-64

pyoptinterface-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyoptinterface-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl (815.4 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

File details

Details for the file pyoptinterface-0.2.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 af415d9fec0369cacafd181a2715f90a3c4a4d3850e8db3baf7a0afd747e29d3
MD5 dd5d90e65f71af11f60d22aed1b2f363
BLAKE2b-256 8ae9c49ae89685f7d29979cc4bc0547673b1c904379146d30a3c4d452d0db21f

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54319d916cfc95ab2feb784322f4ffb5e410f89167d702dc0cf75b6571aa770d
MD5 34363cc5dc2949f6bd6b19a771f138bc
BLAKE2b-256 43c2017b0f7799ae56e93d3c921eea7f0827146e9b042b138627fd4ef5937794

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5953f764553c262e86478cb561e167ff4bb7b8177f9678672fa6f5b15ba618c8
MD5 3f973994c84b6a6433f0e1a13e49bae3
BLAKE2b-256 dbd55fddfeaaae1b56448c0f8d54d59a3d30a340be590042cc7e857395904fa9

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp312-cp312-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 3e33a6faf427394c8472a49b2ebd703290e1a98e8a0dde214a7147a1b5b47eb6
MD5 63b3f1cc9bb74019b36d40073cc461da
BLAKE2b-256 4153eae2c40bfe45b49fc2f23ac6dbb3c368af0aec8299c98dcb5e4f83ca0733

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cd8fe6752d85a6a64b99a81cd2bc6d7bd1109b9d771b9b6fb8d8da08833a883f
MD5 fcebd07d87439a91ce9cecd51effe98c
BLAKE2b-256 90bc2f24971a03d3db4551ebddb1bff7fd5f0b34a73880b9a5b232d37a65383f

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 db8876fb556bf9d1a4e38ced7d81958d6c1bf947af3a8909eb66d4a7b41850aa
MD5 e238c0d34f49feba28c93f9a79a04857
BLAKE2b-256 4abc1d3a58c281ebeabe6cb917d695a38f806756040b4f381cc1c3f487045c8f

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8eaa587c60a074780083c6379723acfa9de2eabe816b51f9f6b7f4b5848a46f5
MD5 77cbefe982df6cde9e1704c3381f2c17
BLAKE2b-256 34e8d274d621cbea552a1a96d18dc3edfb97e634bdf313e3599f20c21ae655f4

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp311-cp311-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 69677e282dd0e1d3673956e7d0d78fa454ee0cdfd11bfcd67212c21bf1b0e4a3
MD5 263b7524a4cf699afd68790ecc644429
BLAKE2b-256 6d93d633cc5ce017e6f7710c121d52a7ff03ecd8fe367c9369178fdb6ba5f9be

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9a5e5f91bbd11542dec65403f296a247a36866cf3cfdd256bfe51c9f66e5a2ba
MD5 8794a709a8772fb0519936222ff0a609
BLAKE2b-256 2219313ccf7e37afdd27c8027ef91bc7c375deec4aa1f0140e7f7a98d1320343

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 30d4a6ac9e7934d692e2b5481a3889f412e3fa7b7a9b9bcc7d21e50bd72f7480
MD5 fc4f2e57311fde61fd8ac33f3bdff55e
BLAKE2b-256 8d19cc78c3e6d0e47362313a53aab10e06e18bb8c91aa93de552d1dbf3e4903f

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 29ba0f30af2a4ac237ac0f1970026ead742e6bd9da3461725ef9111a72890a7a
MD5 813dc5e6794206d537a83061cbcba6f6
BLAKE2b-256 0069dbbdf45e8a0536d36781fd32e50ef947367408b2867a9a9cf6a8c26120d6

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp310-cp310-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 708316fca55ad600ec310149116ac2f4720f81ab27cee45bb6dc7f154c117ebe
MD5 1dcb4e47246a94596ddd1bb6335ce940
BLAKE2b-256 648603989ab4b32a3d80b101db1fa3926be3f4acd706a60705d5df9715d5ccf2

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e164376427e923a5242498e9f916f0347b20f8d8f58cdf36b1499553448150fd
MD5 a5e06fb7daf863c0b1c1b9b441a5287c
BLAKE2b-256 b2f618b065a1bc54f3ab6ca8af90b300aebb045ab111500c4f80ec1210dbbb2b

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e99c884fe3ec47341c4b990b9b5952e99c0fa332d08063f6829239c6384f242
MD5 56442bf35ae033ce658eb197fd5a2307
BLAKE2b-256 ff9dcf7cb63b32832141d595daa19a3946c203e45c8bdc2b7dde1586ad6651d3

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fb75350c924beac6f9bfaeec7d667666a5ccce2bddca0c3e8623a4993b8ddb5d
MD5 963214b880e47f735a682847e00e9b57
BLAKE2b-256 1cf6d5bfef052b381e63254f32ed7b450dbf73276a070607773cdaa714f4c502

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 1733a0b836ee9b65428ac70f0c6335b1ab878ccb255178f30caad3974fe703ab
MD5 de5c37fa73797f266ed3f96536bb39da
BLAKE2b-256 691e3d83655d6014e29b881a73712dd016cbbbddb2e1a50b9bc014c05fc226bc

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 3060602e888a737b414c5bfc7d50ee66226c05d6a44d12bbe0c49f7249f6f271
MD5 a19e0fcc67a28d937b57690751ee7050
BLAKE2b-256 16e34758b89a90e308c4a4da9b689d040833a3741506732a5aaa7746aba633e4

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3c5d715915373873438699ed326ef32a790b905e3423cb3e0a3bc9fd89b745d4
MD5 e8f6a2d170f09afa27f114b5a5691f06
BLAKE2b-256 3a294ac1a768f8a17c718472d9cc21a82ce049bee4833a49ad5a1bc6460c8be9

See more details on using hashes here.

File details

Details for the file pyoptinterface-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 1e291cec0a69f9fab4dfd54a6b89997f46be0b23e504e7e5a8ec505fea048677
MD5 45c97aece96709f002d5618a8734e545
BLAKE2b-256 68ba4a646eb35f403a8413d0c08beeb65d0a91e96ddd0f79cb4aafc638bbe4c2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page