{"id":18669236,"url":"https://github.com/metab0t/pyoptinterface","last_synced_at":"2025-08-19T11:32:26.230Z","repository":{"id":231121812,"uuid":"653217716","full_name":"metab0t/PyOptInterface","owner":"metab0t","description":"Efficient modeling interface for mathematical optimization in Python","archived":false,"fork":false,"pushed_at":"2024-04-22T09:48:57.000Z","size":2051,"stargazers_count":82,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-29T10:38:41.145Z","etag":null,"topics":["conic-programs","linear-programming","mathematical-modelling","mathematical-programming","mixed-integer-programming","modeling-language","optimization","python","quadratic-programming"],"latest_commit_sha":null,"homepage":"https://metab0t.github.io/PyOptInterface/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metab0t.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-13T16:11:33.000Z","updated_at":"2024-05-12T21:41:04.578Z","dependencies_parsed_at":"2024-05-12T22:31:43.413Z","dependency_job_id":null,"html_url":"https://github.com/metab0t/PyOptInterface","commit_stats":null,"previous_names":["metab0t/pyoptinterface"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metab0t%2FPyOptInterface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metab0t%2FPyOptInterface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metab0t%2FPyOptInterface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metab0t%2FPyOptInterface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metab0t","download_url":"https://codeload.github.com/metab0t/PyOptInterface/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230351169,"owners_count":18212788,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conic-programs","linear-programming","mathematical-modelling","mathematical-programming","mixed-integer-programming","modeling-language","optimization","python","quadratic-programming"],"created_at":"2024-11-07T08:46:18.619Z","updated_at":"2025-08-19T11:32:26.188Z","avatar_url":"https://github.com/metab0t.png","language":"C++","readme":"PyOptInterface (Python Optimization Interface)\n=======\n\n[![](https://img.shields.io/pypi/v/pyoptinterface.svg?color=brightgreen)](https://pypi.org/pypi/pyoptinterface/)\n\n**PyOptInterface** is an open-source Python library to provide a unified API to construct and solve optimization models with various optimizers.\n\nThe detailed documentation can be found [here](https://metab0t.github.io/PyOptInterface/).\n\n## Key features compared with other modeling interfaces\nIt 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.\n\nThe key features of PyOptInterface include:\n- 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)\n- Highly efficient structured automatic differentiation for nonlinear optimization with JIT compilation (faster than other NLP frameworks)\n- Low overhead to modify and re-solve the problem incrementally (including adding/removing variables/constraints, changing objective function, etc.)\n- Unified API to cover common usages, write once and the code works for all optimizers\n- 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\n\n## Benchmark\nThe benchmark comparing PyOptInterface with some other modeling interfaces can be found [here](https://metab0t.github.io/PyOptInterface/benchmark.html). PyOptInterface is among the fastest modeling interfaces in terms of model construction time and automatic differentiation of nonlinear optimization problems.\n\n## Installation\nPyOptInterface is available on PyPI. You can install it via pip:\n\n```\npip install pyoptinterface\n```\n\nAfter installation, you can import the package in Python console:\n```python\nimport pyoptinterface as poi\n```\n\nPyOptInterface 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](https://metab0t.github.io/PyOptInterface/getting_started.html).\n\nIn order to provide out-of-the-box support for open source optimizers (currently we support [HiGHS](https://github.com/ERGO-Code/HiGHS)), PyOptInterface can also be installed with pre-built optimizers. You can install them via pip:\n\n```\npip install pyoptinterface[highs]\n```\n\nIt will install a full-featured binary version of HiGHS optimizer via [highsbox](http://github.com/metab0t/highsbox), which can be used with PyOptInterface.\n\n## What kind of problems can PyOptInterface solve?\nIt currently supports the following problem types:\n- Linear Programming (LP)\n- Mixed-Integer Linear Programming (MILP)\n- Quadratic Programming (QP)\n- Mixed-Integer Quadratic Programming (MIQP)\n- Quadratically Constrained Quadratic Programming (QCQP)\n- Mixed-Integer Quadratically Constrained Quadratic Programming (MIQCQP)\n- Second-Order Cone Programming (SOCP)\n- Mixed-Integer Second-Order Cone Programming (MISOCP)\n- Exponential Cone Programming (ECP)\n- Mixed-Integer Exponential Cone Programming (MIECP)\n- Nonlinear Programming (NLP)\n\n## What optimizers does PyOptInterface support?\nIt currently supports the following optimizers:\n- [COPT](https://shanshu.ai/copt) ( Commercial )\n- [Gurobi](https://www.gurobi.com/) ( Commercial )\n- [HiGHS](https://github.com/ERGO-Code/HiGHS) ( Open source )\n- [Mosek](https://www.mosek.com/) ( Commercial )\n- [Ipopt](https://github.com/coin-or/Ipopt) ( Open source )\n\n## Short Example\n```python\nimport pyoptinterface as poi\nfrom pyoptinterface import highs\n\nmodel = highs.Model()\n\nx = model.add_variable(lb=0, ub=1, domain=poi.VariableDomain.Continuous, name=\"x\")\ny = model.add_variable(lb=0, ub=1, domain=poi.VariableDomain.Integer, name=\"y\")\n\ncon = model.add_linear_constraint(x + y \u003e= 1.2, name=\"con\")\n\nobj = 2*x\nmodel.set_objective(obj, poi.ObjectiveSense.Minimize)\n\nmodel.set_model_attribute(poi.ModelAttribute.Silent, False)\nmodel.optimize()\n\nprint(model.get_model_attribute(poi.ModelAttribute.TerminationStatus))\n# TerminationStatusCode.OPTIMAL\n\nx_val = model.get_value(x)\n# 0.2\n\ny_val = model.get_value(y)\n# 1.0\n```\n\n## Citation\nIf you use PyOptInterface in your research, please consider citing [the following paper](https://arxiv.org/abs/2405.10130):\n\n```bibtex\n@misc{yang2024pyoptinterface,\n      title={PyOptInterface: Design and implementation of an efficient modeling language for mathematical optimization}, \n      author={Yue Yang and Chenhui Lin and Luo Xu and Wenchuan Wu},\n      year={2024},\n      eprint={2405.10130},\n      archivePrefix={arXiv},\n      primaryClass={cs.MS}\n}\n```\n\nIf you use the nonlinear optimization feature of PyOptInterface, please consider citing [the following paper](https://ieeexplore.ieee.org/document/10721402) as well:\n\n```bibtex\n@article{yang2024accelerating,\n      title={Accelerating Optimal Power Flow with Structure-aware Automatic Differentiation and Code Generation},\n      author={Yang, Yue and Lin, Chenhui and Xu, Luo and Yang, Xiaodong and Wu, Wenchuan and Wang, Bin},\n      journal={IEEE Transactions on Power Systems},\n      year={2024},\n      publisher={IEEE}\n}\n```\n\n## License\nPyOptInterface is licensed under MPL-2.0 License.\n\nIt uses [nanobind](https://github.com/wjakob/nanobind), [fmtlib](https://github.com/fmtlib/fmt) and [martinus/unordered_dense](https://github.com/martinus/unordered_dense) as dependencies.\n\nThe design of PyOptInterface is inspired by [JuMP.jl](https://jump.dev).\n\nSome solver-related code in `src` folder is adapted from the corresponding solver interface package in `JuMP.jl` \necosystem, which is licensed under MIT License.\n\nThe header files in `thirdparty/solvers` directory are from the corresponding distribution of optimizers and are licensed under their own licenses.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetab0t%2Fpyoptinterface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetab0t%2Fpyoptinterface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetab0t%2Fpyoptinterface/lists"}