spec: from_spec spends about 2 ms per constraint entry, whatever its size
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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 18/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- performance
Hướng nghiên cứu
Start with the reproducer in the issue, which times Model.from_spec per constraint entry at two grid sizes. The profile points at where / admits_a_row, _constraints and _objective, so read those in the spec code path first. The issue does not say what to change, and the work is performance investigation with an open design question. Done means a measured drop in per-entry cost that the maintainers accept.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[!NOTE]
The following content was generated by AI.
Model.from_spec has a fixed cost of about 2 ms per constraint entry. The grid size hardly changes it:
| grid | 10 entries | 200 entries |
|---|---|---|
| 2 × 2 | 2.38 ms per entry | 2.06 ms per entry |
| 200 × 200 | 2.87 ms per entry | 2.62 ms per entry |
Measured on stack/spec-perf (master + #1155, #1156, #1157), Python 3.13, 4 cores, spec lowered beforehand, best of 3.
This dominates real builds: in PyPSA/PyPSA#2128, from_spec is 79–84% of a warm create_model, and a network 300× larger costs only 0.43 s more. A profile of that build points at where / admits_a_row, _constraints and _objective. A spec with one flat name dimension will have fewer entries, but the cost per entry still sets the floor.
Reproducer
import time
import xarray as xr
from linopy import Model
from linopy.spec import lowered
def spec(n: int) -> dict:
constraints = {
f"c{i}": {"dims": ["t", "g"], "where": "active", "expression": f"x <= {i + 1}"}
for i in range(n)
}
return {
"dimensions": {"t": {"dtype": "str"}, "g": {"dtype": "str"}},
"parameters": {"active": {"dims": ["t", "g"], "dtype": "bool"}},
"variables": {"x": {"dims": ["t", "g"], "bounds": {"lower": 0}}},
"constraints": constraints,
"objective": {"sense": "minimize", "expression": "sum(x)"},
}
for size in (2, 200):
t, g = [f"t{i}" for i in range(size)], [f"g{i}" for i in range(size)]
active = xr.DataArray(True, coords={"t": t, "g": g}, dims=["t", "g"]).copy()
sources = {"t": t, "g": g, "active": active}
for n in (10, 200):
program = lowered(spec(n))
times = []
for _ in range(3):
start = time.perf_counter()
Model.from_spec(program, sources)
times.append(time.perf_counter() - start)
print(f"{size}x{size}, {n} entries: {1000 * min(times) / n:.2f} ms per entry")
Part of PyPSA/PyPSA#2138.
- Ngôn ngữ chính
- Python
- Star
- 264
- Fork
- 95
- Merge trung bình
- 11 giờ 33 phút
- Pull request đã merge (30 ngày)
- 86
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của PyPSA/linopy
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
Maintainer thường phản hồi trong vòng 1 ngày
-
feature needs triage
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
PyPSA/linopy#1180 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
spec: a row emptied by the data is refused even when it holdsCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Gurobi raises GurobiError when a MIP stops at a limit without an incumbentCó thể đã có người làm @Blizzeq đã nhận 15 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Rose22/openlumara#166 ·
-
documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement feature/signals self-driving team/self-driving
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
PostHog/posthog#144208 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue help wanted tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
LMPrado-DZ23/open_notas_br#14 ·
Maintainer thường phản hồi trong vòng 1 ngày