linopy is an open-source python package that facilitates optimization with real world data. It builds a bridge between data analysis packages like xarray & pandas and problem solvers like cbc, gurobi (see the full list below). Linopy supports Linear, Integer, Mixed-Integer and Quadratic Programming while aiming to make linear programming in Python easy, highly-flexible and performant.
linopy is heavily based on xarray which allows for many flexible data-handling features:
- Define (arrays of) contnuous or binary variables with coordinates, e.g. time, consumers, etc.
- Apply arithmetic operations on the variables like adding, substracting, multiplying with all the broadcasting potentials of xarray
- Apply arithmetic operations on the linear expressions (combination of variables)
- Group terms of a linear expression by coordinates
- Get insight into the clear and transparent data model
- Modify and delete assigned variables and constraints on the fly
- Use lazy operations for large linear programs with dask
- Choose from different commercial and non-commercial solvers
- Fast import and export a linear model using xarray's netcdf IO
So far linopy is available on the PyPI repository
pip install linopy
or on conda-forge
conda install -c conda-forge linopy
linopy supports the following solvers
Note that these do have to be installed by the user separately.
If you use Linopy in your research, please cite the following paper:
- Hofmann, F., (2023). Linopy: Linear optimization with n-dimensional labeled variables. Journal of Open Source Software, 8(84), 4823, https://doi.org/10.21105/joss.04823
A BibTeX entry for LaTeX users is
@article{Hofmann2023,
doi = {10.21105/joss.04823},
url = {https://doi.org/10.21105/joss.04823},
year = {2023}, publisher = {The Open Journal},
volume = {8},
number = {84},
pages = {4823},
author = {Fabian Hofmann},
title = {Linopy: Linear optimization with n-dimensional labeled variables},
journal = {Journal of Open Source Software}
}
Copyright 2021 Fabian Hofmann
This package is published under MIT license. See LICENSE.txt for details.