CSR constraints: support `update()` instead of raising frozen errors
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
Start with CSRConstraint and Constraint.update() in linopy/constraints.py, then trace how the CSR store represents active rows and sparsity patterns. Check the existing constraint update tests and persistent backend snapshot diff; add coverage for rhs, sign, coeffs, lhs, and pattern changes. Done means supported updates keep the constraint sparse and a changed coefficient pattern raises.
索引モデルが issue の本文から書いたものです。
説明
this came up as a missing gap for making the sparse model and equivalent backend to the dense
[!NOTE]
The following content was generated by AI.
Describe the feature you'd like to see
In a sparse model every constraint is a CSRConstraint. It cannot be changed: update() and all setters raise, and the only way out is mutable(), which converts the constraint to dense. Changing the right-hand side between solves (rolling horizon, persistent re-solves, sensitivity runs) therefore costs a full densification and gives up the sparse path.
import pandas as pd
import linopy
linopy.options["semantics"] = "v1"
m = linopy.Model(sparse=True)
x = m.add_variables(lower=0, coords=[pd.RangeIndex(3, name="i")], name="x")
c = m.add_constraints(x >= 1, name="c")
c.update(rhs=2)
# AttributeError: CSRConstraint.update is not supported on a frozen constraint; call .mutable() to modify.
Expected: c.update(rhs=2) changes the right-hand side and c stays a sparse constraint.
Proposed direction
Implement CSRConstraint.update() with the same signature as Constraint.update() (linopy/constraints.py:1954), on the CSR store:
| Argument | Implementation |
|---|---|
rhs, sign |
replace the per-row arrays (aligned to the active rows) |
coeffs |
replace the data array on the existing sparsity pattern; a pattern change raises |
lhs |
rebuild the CSR from the new expression |
scaling is managed by the scaling module and stays read-only for users.
This is part of retiring freezing as a user concept (#1019, step 3): once the CSR store can be updated, freeze=, freeze() and mutable() can be deprecated in favour of the model's sparse key and to_sparse() / to_dense(). Persistent backends should pick up the change through the existing snapshot diff.
- 主要言語
- Python
- スター
- 260
- フォーク
- 89
- 平均マージ
- 2日 11時間
- マージ済み PR(30日)
- 26
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PyPSA/linopy のほかの issue
-
bug solver interface
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
refactor sparse
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
Meta: separate dense and sparse stores from the expression and constraint frontend再び着手できるかも @Rishabhkanhaiya が 14 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンdiscussion refactor sparse
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
PyPSA/linopy#1019 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
refactor sparse
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
メンテナーはふだん 1 日以内に返信
-
discussion math-spec
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
pgvector/pgvector-python#169 ·
-
ChaosEngine: backup-remote doctor row passes while consumer mode hides bot memory from git対応中かも @MohabMohie が今日担当しました。 オープンagentic
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ShaftHQ/SHAFT_ENGINE#7263 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
huggingface/smolagents#3045 ·
メンテナーはふだん 1 日以内に返信