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)
  • Exponential Cone Programming

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

Citation

If you use PyOptInterface in your research, please consider citing the following paper:

@misc{yang2024pyoptinterface,
      title={PyOptInterface: Design and implementation of an efficient modeling language for mathematical optimization}, 
      author={Yue Yang and Chenhui Lin and Luo Xu and Wenchuan Wu},
      year={2024},
      eprint={2405.10130},
      archivePrefix={arXiv},
      primaryClass={cs.MS}
}

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.8-cp312-cp312-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.12 Windows x86-64

pyoptinterface-0.2.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyoptinterface-0.2.8-cp312-cp312-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

pyoptinterface-0.2.8-cp312-cp312-macosx_10_14_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12 macOS 10.14+ x86-64

pyoptinterface-0.2.8-cp311-cp311-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.11 Windows x86-64

pyoptinterface-0.2.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyoptinterface-0.2.8-cp311-cp311-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pyoptinterface-0.2.8-cp311-cp311-macosx_10_14_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11 macOS 10.14+ x86-64

pyoptinterface-0.2.8-cp310-cp310-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.10 Windows x86-64

pyoptinterface-0.2.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyoptinterface-0.2.8-cp310-cp310-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pyoptinterface-0.2.8-cp310-cp310-macosx_10_14_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.10 macOS 10.14+ x86-64

pyoptinterface-0.2.8-cp39-cp39-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.9 Windows x86-64

pyoptinterface-0.2.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyoptinterface-0.2.8-cp39-cp39-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pyoptinterface-0.2.8-cp39-cp39-macosx_10_14_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.9 macOS 10.14+ x86-64

pyoptinterface-0.2.8-cp38-cp38-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.8 Windows x86-64

pyoptinterface-0.2.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyoptinterface-0.2.8-cp38-cp38-macosx_10_14_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 13285ac5f54e82f91d10d777973e37b2e290313236f06e93318c07bb9158704d
MD5 4cb15d76a46d54f5a9a6c72c73dd30bd
BLAKE2b-256 26708a2ab84d6e0d456710b3965b4cce9f20ec2d105132f7165ac51d3cbd411e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7a928f9ac8fb79491f470cf52b54719f2e797311021ac3e4a4c73c6fef25e534
MD5 066689df126c1a329195c7397aa8ecb2
BLAKE2b-256 91fa0be61773e0828a26a000b3b63257811e59284f10b7c46ef1eb23e92ef5e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8b8fc3af435eb010dabf258f3514f7007438200000520a9afc77ed9beaabd931
MD5 cc3dac32b316ea8d6cae5a0456eb0c6d
BLAKE2b-256 9f6baee88381c8cd9fad1f23d2b335ae4eb6bdc369f4d0d3fa7d3672c9d90afb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ec02437f434baf3e2e1f46fed75aa43dd02a28496e5e9a0b4c3d9b03f43dd809
MD5 7f7bd22cce999c2e883bc530ab2139c2
BLAKE2b-256 bce64c3dfa9ac681204f39939885f9bf9970e96d1a6e1aa65685a18892d60987

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6b233dc6066e1e142000e22a57e3aaaff0315bfd384cd9118c1f6daf0d97c4f7
MD5 e188f80b3ee99df11e6be6bef9ae1ac2
BLAKE2b-256 fa60a01ab34d5bcec0e0f1ff6c64c95b6861309672a002e746f9550992da9bd0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9421af2ccda2ebba92845b17d88d92b6283db2a5753aa9d7463f96c42865b2e0
MD5 4a6bb1b08807163c922f8e877e4228a8
BLAKE2b-256 61581f0279c716cf722fef45fb1c730df657bf552ab2d8a34b9bc81775843abd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f5573a88cd8b3d61e85a13a78ca088454a86f94bc6f5768b54b0c703954e390f
MD5 0592adf175d6dc66c5f99c2cceb712fa
BLAKE2b-256 c8fb626974573500369e58d829138b647d200492eabe6b72ab89479215e6ddff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 9cf468f4aad1c0536b21e20ca8387d4eb8386e992d14b17cfced2633f4ac2e6c
MD5 d66f544074ffb1e4a981818105fafc4c
BLAKE2b-256 79939dbdb0dc4650bcc96a269bdc36d530f81c244c8b25aab9bedaa7c2e9c059

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ab13879b7e65ce0df12d0abe3c4c73f55aacef4e14b1f3a723abf6cc525d3877
MD5 318b746a4d62be30b569eb63a2cf66c9
BLAKE2b-256 af47ce94c34988fbbea6411a5f5dfa0c3d16d35b6e84f5f6d951efa7f1a8588b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a1a9de839f13812683d74852af176f00317a004b5d3bb9bc2cb2338f51c3d285
MD5 186f648ffcd486f745bda2653451adc7
BLAKE2b-256 50f54cd15846ebf4360ffe79f1284b53ad05c3498e81bbada70ef97da35dc74a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 07f62e5a6fa972a2ce5b10fdc74edf38b3ed2d699779a29691ecbbeec251d1f5
MD5 b4a13cde5619c0aeab4270b81120b2e1
BLAKE2b-256 c50e52cc3a9e794b9cec313fb72bd29f89f2ab2686e8648a28c0a65459c8e37f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 484745f3f1da7fc7c70436b7c18475c0b2a12b2bb145da81b32ba6824ac8232c
MD5 73851fe68be4d94dd1ee8cb0da0fc4c7
BLAKE2b-256 232d1d88c22ae45b8575d9356b62e34615a633742d61b88b0a0e1b8a934870e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 42e4a5964240fd8d094d7f3a4becd280b2dc7f4a9c7f1f4c4e7413319b5c676c
MD5 ea605c0864f724801abded61a0d0177c
BLAKE2b-256 df33c172a322a7cfe096c1b1cf50d320bb654de13a5babdb49cc4306a815886b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 caed0d9d9d51c5dc36f78aeb314577acab5272155a0913fbedf7b2bc64616ec4
MD5 28e30b383bc45d8e4c3f3a0cdbd93c0c
BLAKE2b-256 ffeb7ddbb46bf042a8e8aa1d3766f21c0fe98c265416d2ab20b05eca5cec99a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0f7647b21d4bccfbad1029fb8da84ebbab388bf2cd405b222ab17274bc8e0196
MD5 a871624c515d986593c74a1082cc4a2b
BLAKE2b-256 ac692e37ddb0efc398770b872f5402ef1053c38023f0a458d614cf6c5bca5933

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d1c3fe5011f3fbd53bb84294efc75e83e7e1a1bb443081691f988f93399f948d
MD5 4228a1fdd67a27e75befc2b81b105ccb
BLAKE2b-256 42223995624133348cdccd9771a2d682b565f30bc5281058076fbd159d79493e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b05df942a699b80a15bde07bd9741e15f26204c6fe58b8c87eb4ac0273879544
MD5 839111c1e7d6cb6cd960967c62e2cee9
BLAKE2b-256 295030b924c4dc7e6583ffd5ce518d384224712a590064d9b091eb4108a8e76e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f2e8c0abbe82bc4286c5e5ccd121a90b433ee6edeb4fb973c847b482801eb7f9
MD5 0e4e521515f543ace5ff46e3b18d81c2
BLAKE2b-256 496a598c0249a9c9200e7cf51e3fe38828fabf44e0c5cc56c1477c234c25aa7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.8-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 5cb02b12a2f74db919f1a6a80007bd30f1e32f154d2c75883f64c128109badc9
MD5 020c412eb67abd4bdd1b575c182d167d
BLAKE2b-256 2f751de6e6948923040a7997e10c7a502ffbd05a6025785647ca0e35f811bc2c

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