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

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

Uploaded CPython 3.12 Windows x86-64

pyoptinterface-0.2.3-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.3-cp312-cp312-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

pyoptinterface-0.2.3-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.3-cp311-cp311-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.11 Windows x86-64

pyoptinterface-0.2.3-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.3-cp311-cp311-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pyoptinterface-0.2.3-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.3-cp310-cp310-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.10 Windows x86-64

pyoptinterface-0.2.3-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.3-cp310-cp310-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pyoptinterface-0.2.3-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.3-cp39-cp39-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.9 Windows x86-64

pyoptinterface-0.2.3-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.3-cp39-cp39-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pyoptinterface-0.2.3-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.3-cp38-cp38-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.8 Windows x86-64

pyoptinterface-0.2.3-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.3-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.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2ecb77794bf54c36966ed108c57ad34911a2d8932fabdce94f7fcb8ed305caab
MD5 46ce1710b84ff190e47a6e32eb9b4ee2
BLAKE2b-256 92c7cbc708de0c7b1c59fb80d1b22bde575ecac6984fbedf942166566255f073

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1011f2503a7e3ecc39ed14266b6bd4b5446a91d81b1e6ae52b6d4c6fbc9cde4c
MD5 a05411e999b6f8c7124e3f731fdf31b0
BLAKE2b-256 55337132838090684c349dfd4a1d7e2f12b1fd8006c5b0a73b7d60fa10bcde17

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 48796423f4ee9728a302087247c449057d0f6f17a638ecb784ca3227623a8a10
MD5 f4ce56b0fb0338fcb656bad54b6ce6ac
BLAKE2b-256 28d785b74f512f32f817e0f2aa47f103edebb3b68bd5db59ae334b325a0d4aa7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d03c28869f98e82382d47be6daa4e83215e640dbc5bdaf3b13b3551d73294c9d
MD5 ce4cdad1f1676fd17362d8bf8005d0b7
BLAKE2b-256 353dc2671ddb22d0fb0c0ebca29c6047a1bb641e201945fedd39b0f15cfe48c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b215874525f430385aa483d932a6803fb2f191642f44fe07a54933d09c4876e0
MD5 0727549d67c19c56eed08e0e980452bb
BLAKE2b-256 01178d3bcff8fe89adab6cbf2d6fc862c6b6307e80f9e072dcef126b0cf2d4ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 92901c53435c31504bcf8127ac03dd329fa2bb37a87de8f33ec46f25b5ac4b92
MD5 688df65167842f631ffb39fb3be684e5
BLAKE2b-256 46d35c480bc1a69c9096ee90cf5d70aa2d49dbfddb962601e8cb35afa400505a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 42fd197c9b8e82fd541be54bedfaa39e1b49375d6e2c6232b3e489839d61f4da
MD5 0b7252b8dcab8b9e813d6c1dcbb35e00
BLAKE2b-256 0bba1caaba4eba526d93c1233b3145e90627bea5df6af0b0211252efeae019e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 8095a97674810f3b905da71221dc267bb3ba27a945454773b1183b5ee51e2527
MD5 23f9e2af30f33fc0805180dc2e2312ae
BLAKE2b-256 28c4a02924e5b0ba941c40d518d0d07d9d84397900fd14cc03cd905ecbf0cb84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a05f12eb7f6799be32c7caddb3f9867cb4c89121f97553f93e605201574517fa
MD5 598ca6d4271d0bc43da6b02820b911c1
BLAKE2b-256 5777e5626896e349b994e314ead80f8d6d085012c7e45c9c714ab0432b489d97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9993c6ec1e4dfdedb9646bffed533cc88854f344210063de1d8a7558c38ebcf1
MD5 267ccf5575db2c6a4dae83fbebdecfe5
BLAKE2b-256 88dfb3cc93c65e3616c9c67ebce796e2a353c3937f278ae0885b9166fe3cef95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b9bb926f502948ad79e9cd28dad138a4df02b20e1fb581e2328d67ffd6cd6c13
MD5 b0e78a2af796ec4d5d68d5b6a4ab8551
BLAKE2b-256 c1e44249ab5d20a6ffb3a0d0c2fd087ea1a0ba2f8634cf57b2c76956933240fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 b663d197ca327bdbb30b46bb603fbfd1931e7bf777aef37fc2acdd67e4934c35
MD5 3acb589397887095da103376d5430e26
BLAKE2b-256 e29036361ca03988767e9ec04804f161fe533d9e33f39f362a0e47994489831f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 56d3e0bf8b02c1c9ccfd6002ff1e1689d673226397331f5ae507e771730c707d
MD5 848c21e55d9408dd3871096ee02cc42f
BLAKE2b-256 3466e9d63eee754f254e39b706be80084269b25c04d57f6a388130f323342e59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cfc92bc3c8cb842b816ddfb5eb1e6e28e28b919f7235f278c0494c25ccf32e84
MD5 285fb0eb35a695c75d820de7888332d4
BLAKE2b-256 a1c63a36318f2bb20df161ac85ed3017d09e3cfa390307171af4a109bf14c0b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a5e3e0aed33caa07ca3a33cdf5e3721de2ae2649929247d558bdc5ea03bf3d71
MD5 6292550693b2be18d1b690a399fd08b4
BLAKE2b-256 98d96b2ce2d210c3811c8c913cbf4b73cc9d954d592d5d78411536170b7ac699

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 27bfe01713d6600bb37c122f6ed3511dc43b889e6aba74de424b061cc0e5eee7
MD5 e1e3c74effdd691907e247b8a04d41b7
BLAKE2b-256 b612ca25120ad9a91dd7cf184af73ccb45b3bfbcf8c4638601eecac63b7e6cdc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 240ca9c9017d43414d09e19ff2a03f59ba24d1e4c5b73416b53a75700e28c496
MD5 660ea88a5a9cbce32887a2b115139f84
BLAKE2b-256 f88c0c5b79a28cd53644c56788635d1a0acf28ca62a746ab0160812a71bebe07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 536aeff9bd55532a8d8c89b399a6a9a11086405853e6f9a7a570cb876305f6ed
MD5 da03cb9dc168dbc1cbd9aabb63a015ef
BLAKE2b-256 8b36a5471ef3a27cd5e3edb8f0f05e2b8578ba70b601a146428c73ef914950fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoptinterface-0.2.3-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c8e074acec7c86ae641d1f2f6770bac9dd24cafddfbdb0fe899698c9635b394d
MD5 5151e5e70d36d0bfd5a3bd5f42b81bae
BLAKE2b-256 f1b2f3001dbc5b968c9577770b9b202c28473419e1bb53750255a7fd3f24c727

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