Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#1,063 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend, databases

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
262
Fork
89
Merge medio
2g 11h
PR unite (30g)
28

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PyPSA/linopy

Tutte le issue di PyPSA/linopy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.