Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#1,033 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend-api-design

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
262
Fork
89
Merge trung bình
2 ngày 8 giờ
Pull request đã merge (30 ngày)
34

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PyPSA/linopy

Tất cả issue của PyPSA/linopy

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.