spec: from_spec spends about 2 ms per constraint entry, whatever its size
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 18/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- performance
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
[!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.
- Lenguaje dominante
- Python
- Estrellas
- 264
- Forks
- 95
- Merge medio
- 11 h 33 min
- PR fusionados (30 d)
- 86
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de PyPSA/linopy
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 58/100
Los mantenedores suelen responder en 1 día
-
feature needs triage
Dificultad 5/5 Más de una semana Aptitud para principiantes 12/100
Los mantenedores suelen responder en 1 día
-
bug needs triage
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
PyPSA/linopy#1180 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
spec: a row emptied by the data is refused even when it holdsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 1 día
-
Gurobi raises GurobiError when a MIP stops at a limit without an incumbentPosiblemente ocupada @Blizzeq la tomó hace 15 días. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
Todos los issues de PyPSA/linopy
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Rose22/openlumara#166 ·
-
documentation good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
enhancement feature/signals self-driving team/self-driving
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
PostHog/posthog#144208 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
good first issue help wanted tests
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
LMPrado-DZ23/open_notas_br#14 ·
Los mantenedores suelen responder en 1 día