Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

CSR constraints: support `update()` instead of raising frozen errors

オープン
#1,033 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 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 の本文から書いたものです。

説明

enhancement sparse

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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PyPSA/linopy のほかの issue

PyPSA/linopy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。