Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

spec: full mathspec relation joins and quadratic constraints (follow-up to #958)

Abierto
#1,063 0 comentarios 0 reacciones 0 asignados Ver en GitHub

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
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Start with linopy.spec and the related follow-up #958 to understand how specs become models and how relation joins are currently handled. Reproduce the failure with the provided operators/at_columns.yaml example; compare behavior against the named mathspec 0.4 examples and examples/pypsa.yaml. Done means those examples build with full relation join semantics and quadratic constraints, while the separate empty-row behavior described for #993 remains out of scope.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement math-spec

[!NOTE]
The following content was generated by AI.

Describe the feature you'd like to see

Follow-up to #958. linopy.spec builds a model from a mathspec 0.4 spec, but reads a relation only as one key column mapping into one value column. Everything else is refused with SpecDataError:

  • relations with several value columns (mathspec examples operators/at_columns.yaml, sum_by_columns.yaml, sum_by_column_lists.yaml)
  • bare relations (no value columns)
  • relations with several key columns (multi-key joins)

Quadratic constraints are refused as well. Together these keep mathspec 0.4 examples/pypsa.yaml from building.

Wanted: full mathspec join semantics for relations, and quadratic constraints, so that pypsa.yaml and the three operators/ examples above build.

Minimal reproduction (operators/at_columns.yaml):

import linopy
import pandas as pd

spec = """
dimensions:
  line: { dtype: str }
  bus: { dtype: str }
relations:
  ends: { key: line, values: { bus0: bus, bus1: bus } }
parameters:
  cap: { dims: [bus] }
variables:
  f: { dims: [line], bounds: { lower: 0 } }
constraints:
  sending_cap:
    dims: [line]
    expression: f <= at(cap, by=ends[bus0])
objective: { sense: minimize, expression: sum(f) }
"""

sources = {
    "line": ["l0"],
    "bus": ["b0", "b1"],
    "ends": pd.DataFrame({"line": ["l0"], "bus0": ["b0"], "bus1": ["b1"]}),
    "cap": pd.Series([1.0, 2.0], index=pd.Index(["b0", "b1"], name="bus")),
}
m = linopy.Model.from_spec(spec, sources)
SpecDataError: relation 'ends' keys ['line'] into ['bus0', 'bus1'], and linopy reads a relation over two columns: one key column mapping into one value column. A bare relation, several key columns or several value columns are not supported yet; split it into single-valued relations.

Related, but a separate decision: rows that absence leaves empty stay refused (operators/shift_by_parameter.yaml), so linopy is stricter than mathspec's "not built and reported". See #993.

Lenguaje dominante
Python
Estrellas
262
Forks
89
Merge medio
1 d 13 h
PR fusionados (30 d)
32

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PyPSA/linopy

Todos los issues de PyPSA/linopy

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.