linopy.constraints.Constraints

linopy.constraints.Constraints#

class linopy.constraints.Constraints(data=<factory>, model=None)#

A constraint container used for storing multiple constraint arrays.

__init__(data=<factory>, model=None)#

Methods

__init__([data, model])

add(constraint)

Add a constraint to the constraints constrainer.

get_label_position(values)

Get tuple of name and coordinate for constraint labels.

get_name_by_label(label)

Get the constraint name of the constraint containing the passed label.

items()

print_labels(values[, display_max_terms])

Print a selection of labels of the constraints.

remove(name)

Remove constraint name from the constraints.

reset_dual()

Reset the stored solution of variables.

sanitize_missings()

Set constraints labels to -1 where all variables in the lhs are missing.

sanitize_zeros()

Filter out terms with zero and close-to-zero coefficient.

set_blocks(block_map)

Get a dataset of same shape as constraints.labels with block values.

to_matrix([filter_missings])

Construct a constraint matrix in sparse format.

Attributes

coefficientrange

Coefficient range of the constraint.

coeffs

Get the coefficients of all constraints.

dataset_attrs

dataset_names

dual

Get the dual values of all constraints.

equalities

Get the subset of constraints which are purely equalities.

flat

Convert all constraint to a single pandas Dataframe.

inequalities

Get the subset of constraints which are purely inequalities.

labels

Get the labels of all constraints.

loc

model

ncons

Get the number all constraints effectively used by the model.

rhs

Get the right-hand-side constants of all constraints.

sign

Get the signs of all constraints.

vars

Get the variables of all constraints.

data