--- id: linopy version: "0.9.0" license: unclear license_treatment: permissive maintenance: active --- # linopy — Linear optimization with N-D labeled arrays in Python License: permissive · Maintenance: active · Downloads: 134.2K/mo ## What it is and what it does linopy is a Python optimization modeling framework that lets you define linear, integer, mixed-integer, and quadratic programming problems using labeled n-dimensional arrays. It sits between data-handling libraries like xarray and external solvers, allowing you to express optimization constraints and objectives in a way that mirrors your data's natural structure—with coordinates like time, location, or consumer IDs—rather than flattening everything into matrices. You define variables with bounds and coordinates, build constraints and objectives using arithmetic operations on those variables (with full broadcasting support), and then hand the model off to an external solver of your choice. linopy handles the translation to the solver's format and can import/export models via netCDF. It supports lazy evaluation with dask for large problems and is designed to make the optimization model transparent and easy to modify on the fly. Use it for: - Energy system planning: optimize generation and storage across time and regions with coordinate-based constraints. - Supply chain optimization: define inventory, production, and distribution variables indexed by product, location, and time period. - Resource allocation: minimize cost or maximize utility subject to constraints on budget, capacity, or demand across labeled dimensions. - Scheduling problems: model shift assignments or task scheduling using time and agent coordinates with linear constraints. - Portfolio optimization: construct investment problems with asset and time-period coordinates and quadratic objectives. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. linopy builds linear, integer, and quadratic optimization models using labeled n-dimensional arrays, bridging xarray data structures with external solvers. Yes. linopy is actively maintained, has low install friction, carries no known vulnerabilities, and offers a genuinely useful abstraction for optimization problems that naturally live in labeled arrays. Install it if you need to build optimization models with xarray-like data structures or if you want to avoid hand-coding matrix construction for multi-dimensional problems. The trade-off is that you must install a solver separately; linopy alone is only the modeling layer. ## Install pip install linopy uv add linopy poetry add linopy ## Installing linopy Before you install: Low install friction with a pure-Python wheel distribution. Active maintenance with a recent release (21 days old) and ongoing commits. Depends on well-established packages like numpy, scipy, xarray, and dask; no compiled system dependencies required by linopy itself. License in practice: MIT license (permissive) means you can use, modify, and distribute linopy freely in commercial or private projects with minimal restrictions—only attribution and license inclusion required. Quickstart: import linopy m = linopy.Model() apples = m.add_variables(lower=0, name="apples") bananas = m.add_variables(lower=0, name="bananas") m.add_constraints(3 * apples + 2 * bananas >= 8, name="daily_vitamins") m.objective = apples + bananas m.solve() Requires an external solver (CBC, GLPK, HiGHS, SCIP, Gurobi, Xpress, Cplex, MOSEK, COPT, cuPDLPx, or Knitro) to be installed separately; linopy itself is only the modeling layer. Verify before relying: - Performance comparison claims in the description refer to benchmarks not included in the fact sheet. - Whether lazy operations with dask scale effectively for very large problems is not quantified. - Solver selection and configuration details beyond the supported list are not documented in the excerpt. ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 134.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags linear programming python, optimization with xarray, integer programming solver, constraint optimization arrays, mixed-integer programming, quadratic programming python, optimization labeled variables, optimization, linear-programming, xarray-native [View on SkillFed](https://skillfed.io/packages/linopy) · [View on PyPI](https://pypi.org/project/linopy/)