linopy.constraints.Constraints

linopy.constraints.Constraints#

class linopy.constraints.Constraints(data, model, _label_position_index=None, _constraint_label_index=None)#

A constraint container used for storing multiple constraint arrays.

__init__(data, model, _label_position_index=None, _constraint_label_index=None)#

Methods

__init__(data, model[, ...])

add(constraint[, freeze])

Add a constraint to the constraints container.

format_labels(values[, display_max_terms])

Get a string representation of a selection of constraint labels.

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_infinities()

Remove constraints whose RHS is an invalid infinity.

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()

Construct a constraint matrix in sparse format by stacking per-constraint CSR matrices.

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.

indicator

Get the subset of constraints which are indicator constraints.

inequalities

Get the subset of constraints which are purely inequalities.

label_index

Index for O(1) label->position mapping and compact clabels array.

labels

Get the labels of all constraints.

ncons

Get the number all constraints effectively used by the model.

regular

Get the subset of constraints which are not indicator constraints.

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

model