Widen the CSRConstraint fast path in Model.add_constraints
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- performance
Direzione di ricerca
Start in linopy/model.py around lines 1313-1345 and inspect the CSRConstraint handling in linopy/constraints.py:1427-1441. Trace how mask, penalty, freeze, chunking, and expression right-hand sides affect the sparse path, then define tests showing which cases retain CSR storage without changing existing soft-constraint rules. Done means the agreed cases no longer densify and the current sparse opt-ins remain compatible.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
[!NOTE]
The following content was generated by AI.
Describe the feature you'd like to see
Widen the conditions under which Model.add_constraints keeps a CSRConstraint. Child of #756.
The sparse constraint path is narrow. add_constraints keeps the sparse object only when isinstance(con, CSRConstraint) and freeze and mask is None (linopy/model.py:1333). Any mask=, any penalty=, freeze=False (the default), or a set self.chunk reconstructs the full dense rectangle at model.py:1345.
Upstream of that, csr_rhs (linopy/constraints.py:1427-1441) returns None for a non-constant right-hand side, or one carrying helper dims or dims outside the grid, so to_constraint falls back to dense. An rhs that is itself an expression is a common case and always densifies.
The result is that a build which stayed sparse through every expression operation can still densify at the last step, silently.
Implementation ideas
mask=: a mask is a row selection on the CSR store, the same primitive the sparsewhereneeds. These two should probably be implemented together.- Expression rhs: move the rhs to the left-hand side before building the constraint, which is what the dense path effectively does, then the existing constant-rhs path applies.
penalty/soft constraints are deliberately incompatible with freezing today (model.py:1313); worth confirming that is a permanent rule rather than a gap.
Separately, note that the sparse route currently needs three independent opt-ins to work end to end: semantics="v1", then sparse_groupby=True or a per-call sparse=True, then freeze_constraints=True. Reducing that to one decision would be worth discussing under #756.
- Lingua principale
- Python
- Stelle
- 257
- Fork
- 87
- Merge medio
- 1g 8h
- PR unite (30g)
- 32
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PyPSA/linopy
-
bug solver interface
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
performance sparse
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
documentation sparse
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
-
Make the sparse path observable and controllable (.is_sparse, densify warning, per-call sparse=) Apertaenhancement sparse
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
enhancement performance sparse
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
Tutte le issue di PyPSA/linopy
Issue simili
-
area: harness bug status: needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Human-Agent-Society/reef#625 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
learningequality/kolibri#15351 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Name consistency Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
eellak/triplestore#65 · 1 commento ·