API reference#
This page provides an auto-generated summary of linopy’s API.
Creating a model#
|
Linear optimization model. |
|
Assign a new, possibly multi-dimensional array of variables to the model. |
|
Assign a new, possibly multi-dimensional array of constraints to the model. |
|
Add an objective function to the model. |
Add piecewise linear constraints. |
|
|
Create a breakpoint DataArray for piecewise linear constraints. |
|
Create a segmented breakpoint DataArray for disjunctive piecewise constraints. |
|
Compute tangent-line (chord) expressions for a piecewise linear function. |
|
Create a linopy.LinearExpression from argument list. |
Remove all constraints stored under reference name 'name' from the model. |
|
|
Return a copy of this model. |
Classes under the hook#
Variable#
Variable is a subclass of xarray.DataArray and contains all labels referring to a multi-dimensional variable.
|
Variable container for storing variable labels. |
Get the lower bounds of the variables. |
|
Get the upper bounds of the variables. |
|
|
Sum the variables over all or a subset of dimensions. |
|
Filter variables based on a condition. |
Sanitize variable by ensuring int dtype with fill value of -1. |
|
|
A variables container used for storing multiple variable arrays. |
|
A scalar variable container. |
Variables#
Variables is a container for multiple N-D labeled variables. It is automatically added to a Model instance when initialized.
|
A variables container used for storing multiple variable arrays. |
|
Add a variable to the variables container. |
Remove variable name from the variables. |
|
Get all continuous variables. |
|
Get all integers variables. |
|
Get all binary variables. |
|
Get all integers variables. |
|
Convert all variables to a single pandas Dataframe. |
LinearExpressions#
|
A linear expression consisting of terms of coefficients and variables. |
|
Sum the expression over all or a subset of dimensions. |
|
Filter variables based on a condition. |
Returns a LinearExpressionGroupBy object for performing grouped operations. |
|
|
Rolling window object. |
Create a linear expression by using tuples of coefficients and variables. |
|
|
Merge multiple expression together. |
|
A scalar linear expression container. |
Constraint#
Constraint is a subclass of xarray.DataArray and contains all labels referring to a multi-dimensional constraint.
|
Projection to a single constraint in a model. |
Get the left-hand-side coefficients of the constraint. |
|
Get the left-hand-side variables of the constraint. |
|
Get the left-hand-side linear expression of the constraint. |
|
Get the signs of the constraint. |
|
Get the right hand side constants of the constraint. |
|
Convert the constraint to a pandas DataFrame. |
Constraints#
|
A constraint container used for storing multiple constraint arrays. |
|
Add a constraint to the constraints constrainer. |
Remove constraint name from the constraints. |
|
Coefficient range of the constraint. |
|
Get the subset of constraints which are purely inequalities. |
|
Get the subset of constraints which are purely equalities. |
|
Set constraints labels to -1 where all variables in the lhs are missing. |
|
Convert all constraint to a single pandas Dataframe. |
|
Construct a constraint matrix in sparse format. |
IO functions#
|
Get a fresh created problem file if problem file is None. |
Get a fresh created solution file if solution file is None. |
|
|
Write out a model to a lp or mps file. |
|
Write out the model to a netcdf file. |
|
Read in a model from a netcdf file. |
Solver utilities#
Built-in mutable sequence. |
|
Built-in mutable sequence. |
|
|
Abstract base class for solving a given linear problem. |
Solvers#
|
Solver subclass for the CBC solver. |
|
Solver subclass for the Cplex solver. |
|
Solver subclass for the GLPK solver. |
|
Solver subclass for the gurobi solver. |
|
Solver subclass for the HiGHS solver. |
|
Solver subclass for the Mosek solver. |
|
Solver subclass for the SCIP solver. |
|
Solver subclass for the xpress solver. |
Solving#
|
Solve the model with possibly different solvers. |
|
Solver status. |
|
Termination condition of the solver. |
|
Status and termination condition of the solver. |
|
Solution returned by the solver. |
|
Result of the optimization. |