Linopy: Linear optimization with n-dimensional labeledvariables
Fabian Hofmann
Abstract
Linopy is an open-source package written in Python to build and process linear and mixedinteger optimization with n-dimensional labeled input data.Using state-of-the-art data analysis packages, Linopy enables a high-level algebraic syntax and memory-efficient, fast communication with open and proprietary solvers.While similar packages use object-oriented implementations of single variables and constraints, Linopy stores and processes its data in an array-based data model.This allows the user to build large optimization models quickly and lays the foundation for features such as fast writing to array-oriented scientific data formats, masking, automatic solving on remote servers and model scaling. Statement of needDecades after its inception (Dantzig, 1963), mathematical optimization is nowadays of immense importance for business, industry and governmental decision-making.Optimization is used to address various sorts of complex problems, such as challenges related to climate change, energy transitions, and food supply.Typically, an optimization problem, i.e. a mathematical program, consists of one objective function to be numerically minimized and a set of constraints that restrict the underlying variables to external conditions.Algebraic Modeling Languages (AML) aim at facilitating mathematical programming by allowing the user to formulate large scale, complex problems with a high-level syntax similar to the mathematical notation.The formulated problem is then passed to the solver of choice where a solution is calculated.AMLs provide the most user-friendly interface possible to various solvers, each with its own set of features.Well established AMLs such as GAMS (Bussieck & Meeraus, 2004) and AMPL (Fourer et al., 1990) support a wide range of solvers, but are license-restricted and rely on closed-source code.In contrast, AMLs as JuMP (Dunning et al., 2017), CVXPY (Diamond & Boyd, 2016), Pyomo (Hart et al., 2017), GEKKO (Beal et al., 2018) and PuLP (Mitchel et al., 2022) are open-source and have gained increasing attention throughout the recent years.While the Julia package JuMP is characterized by high-performance, in-memory communication with the solvers, the Python packages Pyomo, GEKKO and PuLP lack parallelized, low-level operations and communicate slower with the solver via intermediate files written to disk.An exception is CVXPY, which supports fast array-based operations and uses low-level wrappers to the solvers.However, it is common among Python AMLs not to make use of state-of-the-art data handling packages.In particular, the assignment of coordinates or indexes is often not supported or memory extensive due to use of an object-oriented implementation where every single combination of coordinates is stored separately.Linopy is an open-source Python package representing a new kind of AML that tackles these issues together.By introducing an array-based data model for variables and constraints, Linopy makes mathematical programming compatible with Python's advanced data handling packages