linopy.constraints.Constraints.to_matrix#
- Constraints.to_matrix()#
Construct a constraint matrix in sparse format by stacking per-constraint CSR matrices.
Each per-constraint CSR is already dense: rows are active constraints only, column indices are dense variable positions (not raw labels). Shape is
(n_active_cons, n_active_vars).- Returns:
matrix (
scipy.sparse.csr_array) – Shape(n_active_cons, n_active_vars).con_labels (
np.ndarray) – Shape(n_active_cons,), maps each matrix row to the original constraint label.