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.
Construct a constraint matrix in sparse format by stacking per-constraint CSR matrices.
Attributes
coefficientrangeCoefficient range of the constraint.
Get the coefficients of all constraints.
dataset_attrsdataset_namesGet the dual values of all constraints.
Get the subset of constraints which are purely equalities.
flatConvert all constraint to a single pandas Dataframe.
Get the subset of constraints which are purely inequalities.
label_indexIndex for O(1) label->position mapping and compact clabels array.
labelsGet the labels of all constraints.
nconsGet the number all constraints effectively used by the model.
Get the right-hand-side constants of all constraints.
Get the signs of all constraints.
Get the variables of all constraints.
datamodel