linopy.constraints.Constraint

linopy.constraints.Constraint#

class linopy.constraints.Constraint(data, model, name='')#

Projection to a single constraint in a model.

The Constraint class is a subclass of xr.DataArray hence most xarray functions can be applied to it.

__init__(data, model, name='')#

Initialize the Constraint.

Parameters:
  • labels (xarray.DataArray) – labels of the constraint.

  • model (linopy.Model) – Underlying model.

  • name (str) – Name of the constraint.

Methods

__init__(data, model[, name])

Initialize the Constraint.

from_rule(model, rule, coords)

Create a constraint from a rule and a set of coordinates.

isel([indexers, drop, missing_dims])

Wrapper for the xarray Dataset.isel function for linopy.Constraint

print([display_max_rows, display_max_terms])

Print the linear expression.

sel([indexers, method, tolerance, drop])

Wrapper for the xarray Dataset.sel function for linopy.Constraint

Attributes

attrs

coeffs

Get the left-hand-side coefficients of the constraint.

coord_dims

coord_sizes

coords

data

Get the underlying DataArray.

dims

dual

Get the dual values of the constraint.

flat

Convert the constraint to a pandas DataFrame.

indexes

is_assigned

labels

Get the labels of the constraint.

lhs

Get the left-hand-side linear expression of the constraint.

mask

Get the mask of the constraint.

model

Get the model of the constraint.

name

Return the name of the constraint.

ndim

nterm

range

Return the range of the constraint.

rhs

Get the right hand side constants of the constraint.

shape

sign

Get the signs of the constraint.

size

sizes

term_dim

Return the term dimension of the constraint.

type

Get the type of the constraint.

values

vars

Get the left-hand-side variables of the constraint.