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 a linear objective function to the model. |
|
Create a linopy.LinearExpression from argument list. |
Remove all constraints stored under reference name name from the model. |
Creating a model with eval
strings (experimental)
|
|
|
|
|
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 variable name. |
Remove variable name from the variables. |
|
Get all binary variables. |
|
Get all non-binary variables. |
|
Get all integers variables. |
|
|
Create an generator which iterates over all arrays in key and flattens them. |
|
Ravel and concate all arrays in key while aligning to broadcast_like. |
|
Get a dataset of same shape as variables.labels indicating the blocks. |
LinearExpressions
|
A linear expression consisting of terms of coefficients and variables. |
|
Sum the expression over all or a subset of dimensions. |
Sum expression over groups. |
|
Create a linear expression by using tuples of coefficients and variables. |
|
|
Merge multiple linear 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. |
Convert the variable array to a xarray.DataArray. |
|
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. |
AnonymousConstraint
AnonynousConstraint
contains all information about lower bounds, upper bounds, sign and right-hand-side of a constraint that is not yet added to a Model
instance.
|
A constraint container used for storing multiple constraint arrays. |
Constraints
|
A constraint container used for storing multiple constraint arrays. |
|
Add constraint name. |
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. |
|
|
Get a dataset of same shape as constraints.labels with block values. |
|
Create an generator which iterates over all arrays in key and flattens them. |
|
Ravel and concate all arrays in key while aligning to broadcast_like. |
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. |
Solvers
|
Solve a linear problem using the cbc solver. |
|
Solve a linear problem using the glpk solver. |
|
Highs solver function. |
|
Solve a linear problem using the cplex solver. |
|
Solve a linear problem using the gurobi solver. |
|
Solve a linear problem using 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. |