Optlang

Optlang: An algebraic modeling language for mathematical optimization - Published in JOSS (2017)

https://github.com/opencobra/optlang

Science Score: 46.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
    11 of 29 committers (37.9%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.7%) to scientific vocabulary
Last synced: 7 months ago · JSON representation

Repository

optlang - sympy based mathematical programming language

Basic Info
Statistics
  • Stars: 263
  • Watchers: 18
  • Forks: 52
  • Open Issues: 32
  • Releases: 52
Created over 12 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog Contributing License Code of conduct Support

README.rst

optlang
=======

*Sympy based mathematical programming language*

|PyPI| |Python Versions| |License| |Code of Conduct| |GitHub Actions| |Coverage Status| |Documentation Status| |Gitter| |JOSS| |DOI|

Optlang is a Python package for solving mathematical optimization
problems, i.e. maximizing or minimizing an objective function over a set
of variables subject to a number of constraints. Optlang provides a
common interface to a series of optimization tools, so different solver
backends can be changed in a transparent way.
Optlang's object-oriented API takes advantage of the symbolic math library
`sympy `__ to allow objective functions
and constraints to be easily formulated from symbolic expressions of
variables (see examples).

Show us some love by staring this repo if you find optlang useful!

Also, please use the GitHub `issue tracker `_
to let us know about bugs or feature requests, or our `gitter channel `_ if you have problems or questions regarding optlang.

Installation
~~~~~~~~~~~~

Install using pip

::

    pip install optlang

This will also install `swiglpk `_, an interface to the open source (mixed integer) LP solver `GLPK `_.
Quadratic programming (and MIQP) is supported through additional optional solvers (see below).

Dependencies
~~~~~~~~~~~~

The following dependencies are needed.

-  `sympy >= 1.0.0 `__
-  `swiglpk >= 1.4.3 `__

The following are optional dependencies that allow other solvers to be used.

-  `cplex `__ (LP, MILP, QP, MIQP)
-  `gurobipy `__ (LP, MILP, QP, MIQP)
-  `scipy `__ (LP)
-  `osqp `__ (LP, QP)



Example
~~~~~~~

Formulating and solving the problem is straightforward (example taken
from `GLPK documentation `__):

.. code-block:: python

    from optlang import Model, Variable, Constraint, Objective

    # All the (symbolic) variables are declared, with a name and optionally a lower and/or upper bound.
    x1 = Variable('x1', lb=0)
    x2 = Variable('x2', lb=0)
    x3 = Variable('x3', lb=0)

    # A constraint is constructed from an expression of variables and a lower and/or upper bound (lb and ub).
    c1 = Constraint(x1 + x2 + x3, ub=100)
    c2 = Constraint(10 * x1 + 4 * x2 + 5 * x3, ub=600)
    c3 = Constraint(2 * x1 + 2 * x2 + 6 * x3, ub=300)

    # An objective can be formulated
    obj = Objective(10 * x1 + 6 * x2 + 4 * x3, direction='max')

    # Variables, constraints and objective are combined in a Model object, which can subsequently be optimized.
    model = Model(name='Simple model')
    model.objective = obj
    model.add([c1, c2, c3])

    status = model.optimize()

    print("status:", model.status)
    print("objective value:", model.objective.value)
    print("----------")
    for var_name, var in model.variables.iteritems():
        print(var_name, "=", var.primal)

The example will produce the following output:

::

    status: optimal
    objective value: 733.333333333
    ----------
    x2 = 66.6666666667
    x3 = 0.0
    x1 = 33.3333333333

Using a particular solver
-------------------------
If you have more than one solver installed, it's also possible to specify which one to use, by importing directly from the
respective solver interface, e.g. :code:`from optlang.glpk_interface import Model, Variable, Constraint, Objective`

Documentation
~~~~~~~~~~~~~

Documentation for optlang is provided at
`readthedocs.org `__.

Citation
~~~~~~~~

Please cite |JOSS| if you use optlang in a scientific publication. In case you would like to reference a specific version of of optlang you can also include the respective Zenodo DOI (|DOI| points to the latest version).

Contributing
~~~~~~~~~~~~

Please read ``__.

Funding
~~~~~~~

The development of optlang was partly support by the Novo Nordisk Foundation.

Future outlook
~~~~~~~~~~~~~~

-  `Mosek `__ interface (provides academic
   licenses)
-  `GAMS `__ output (support non-linear problem
   formulation)
-  `DEAP `__ (support for heuristic
   optimization)
-  Interface to `NEOS `__ optimization
   server (for testing purposes and solver evaluation)
-  Automatically handle fractional and absolute value problems when
   dealing with LP/MILP/QP solvers (like GLPK,
   `CPLEX `__
   etc.)

.. |PyPI| image:: https://img.shields.io/pypi/v/optlang.svg
   :target: https://pypi.org/project/optlang/
   :alt: Current PyPI Version
.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/optlang.svg
   :target: https://pypi.org/project/optlang/
   :alt: Supported Python Versions
.. |License| image:: https://img.shields.io/pypi/l/optlang.svg
   :target: https://www.apache.org/licenses/LICENSE-2.0
   :alt: Apache Software License Version 2.0
.. |Code of Conduct| image:: https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg
   :target: .github/CODE_OF_CONDUCT.md
   :alt: Code of Conduct
.. |GitHub Actions| image:: https://github.com/opencobra/optlang/actions/workflows/main.yml/badge.svg
   :target: https://github.com/opencobra/optlang/actions/workflows/main.yml
   :alt: GitHub Actions
.. |Coverage Status| image:: https://codecov.io/gh/opencobra/optlang/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/opencobra/optlang
   :alt: Codecov
.. |Documentation Status| image:: https://readthedocs.org/projects/optlang/badge/?version=latest
   :target: https://readthedocs.org/projects/optlang/?badge=latest
   :alt: Documentation Status
.. |JOSS|  image:: http://joss.theoj.org/papers/cd848071a664d696e214a3950c840e15/status.svg
   :target: http://joss.theoj.org/papers/cd848071a664d696e214a3950c840e15
   :alt: Publication
.. |DOI| image:: https://zenodo.org/badge/5031/biosustain/optlang.svg
   :target: https://zenodo.org/badge/latestdoi/5031/biosustain/optlang
   :alt: Zenodo Source Code
.. |Gitter| image:: https://badges.gitter.im/biosustain/optlang.svg
   :target: https://gitter.im/biosustain/optlang?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
   :alt: Join the chat at https://gitter.im/biosustain/optlang

Owner

  • Name: openCOBRA
  • Login: opencobra
  • Kind: organization
  • Location: Terra

Community driven constraint-based reconstruction, analysis and modelling of biology

GitHub Events

Total
  • Create event: 2
  • Release event: 1
  • Issues event: 11
  • Watch event: 14
  • Issue comment event: 7
  • Push event: 13
  • Pull request review comment event: 4
  • Pull request review event: 8
  • Pull request event: 6
  • Fork event: 2
Last Year
  • Create event: 2
  • Release event: 1
  • Issues event: 11
  • Watch event: 14
  • Issue comment event: 7
  • Push event: 13
  • Pull request review comment event: 4
  • Pull request review event: 8
  • Pull request event: 6
  • Fork event: 2

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 632
  • Total Committers: 29
  • Avg Commits per committer: 21.793
  • Development Distribution Score (DDS): 0.527
Past Year
  • Commits: 6
  • Committers: 2
  • Avg Commits per committer: 3.0
  • Development Distribution Score (DDS): 0.167
Top Committers
Name Email Commits
Nikolaus Sonnenschein n****n@g****m 299
KristianJensen j****9@g****m 145
Christian Diener c****r@g****m 54
KristianJensen k****j@n****l 34
KristianJensen k****j@n****k 17
carrascomj c****j@g****m 12
braceal b****l@u****u 11
KristianJensen k****j@n****k 6
Joao Cardoso j****a@b****k 6
KristianJensen k****j@n****k 6
Nikolaus Sonnenschein n****n@g****m 6
Moritz E. Beber m****r@p****t 5
Henning Redestig h****d@g****m 5
KristianJensen k****j@n****k 5
KristianJensen k****j@n****k 3
Ali Kaafarani a****i@k****o 2
Elad Noor n****r@e****h 2
João Cardoso j****o@s****m 2
KristianJensen k****j@n****k 2
long-m-r l****r 1
Kristian Jensen d****e@c****m 1
KristianJensen k****j@n****k 1
KristianJensen k****j@n****k 1
Willy Mroczowski w****y@m****e 1
Peter St. John p****n@g****m 1
Matthias König k****t@g****m 1
Alexandre Detiste a****e@g****m 1
Frames White o****x@u****u 1
Justin Taylor t****m 1

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 73
  • Total pull requests: 53
  • Average time to close issues: about 1 year
  • Average time to close pull requests: 2 months
  • Total issue authors: 34
  • Total pull request authors: 15
  • Average comments per issue: 1.7
  • Average comments per pull request: 2.43
  • Merged pull requests: 48
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 4
  • Pull requests: 5
  • Average time to close issues: 29 days
  • Average time to close pull requests: about 1 month
  • Issue authors: 4
  • Pull request authors: 2
  • Average comments per issue: 0.75
  • Average comments per pull request: 0.2
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Midnighter (23)
  • cdiener (13)
  • NGC2023 (3)
  • braceal (2)
  • matthiaskoenig (2)
  • KristianJensen (2)
  • axelvonkamp (2)
  • Paulocracy (2)
  • serdar- (1)
  • djinnome (1)
  • Theorell (1)
  • sjpfenninger (1)
  • taylo5jm (1)
  • hredestig (1)
  • DManowitz (1)
Pull Request Authors
  • cdiener (33)
  • KristianJensen (7)
  • Midnighter (4)
  • phantomas1234 (4)
  • carrascomj (2)
  • Palaract (2)
  • oxinabox (2)
  • a-detiste (2)
  • DWesl (1)
  • taylo5jm (1)
  • pablo-angulo (1)
  • braceal (1)
  • kvikshaug (1)
  • ConnectedSystems (1)
  • hredestig (1)
Top Labels
Issue Labels
enhancement (9) bug (4) in progress (2) epic (1) refine (1)
Pull Request Labels
in progress (6) ready (2) enhancement (2)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 38,445 last-month
  • Total docker downloads: 801
  • Total dependent packages: 16
  • Total dependent repositories: 105
  • Total versions: 71
  • Total maintainers: 2
pypi.org: optlang

Formulate optimization problems using sympy expressions and solve them using interfaces to third-party optimization software (e.g. GLPK).

  • Versions: 71
  • Dependent Packages: 16
  • Dependent Repositories: 105
  • Downloads: 38,445 Last month
  • Docker Downloads: 801
Rankings
Dependent packages count: 0.7%
Docker downloads count: 1.4%
Dependent repos count: 1.5%
Average: 2.9%
Downloads: 2.9%
Stargazers count: 4.6%
Forks count: 6.0%
Last synced: 7 months ago

Dependencies

.github/workflows/main.yml actions
  • actions/checkout v2 composite
  • actions/create-release v1 composite
  • actions/setup-python v2 composite
requirements_rtd.txt pypi
  • sphinx-rtd-theme >=0.1.6