Skip to content

refactor: openTEPES/{oT_IO,oT_Solver,cases}/ layered subpackages + Benders#123

Open
erikfilias wants to merge 3 commits into
masterfrom
refactor/io-schema-split
Open

refactor: openTEPES/{oT_IO,oT_Solver,cases}/ layered subpackages + Benders#123
erikfilias wants to merge 3 commits into
masterfrom
refactor/io-schema-split

Conversation

@erikfilias
Copy link
Copy Markdown
Contributor

@erikfilias erikfilias commented May 28, 2026

Summary

Layered restructure of the openTEPES package bundled with a Benders compatibility test and CI matrix extension. Breaking import + path changes — no shim.

Structural changes

openTEPES/cases/ all 9 case studies move here (was top-level)
openTEPES/oT_IO/ Schema, Source, CSVSource, DuckDBSource (was openTEPES_InputSource.py)
openTEPES/oT_Solver/ Persistent, Tuning, DualExtraction, ProblemSolving, Benders (was openTEPES_ProblemSolving.py + new)

Breaking changes for users

  • from openTEPES.openTEPES_InputSource import … → from openTEPES.oT_IO import …
  • from openTEPES.openTEPES_ProblemSolving import ProblemSolving → from openTEPES.oT_Solver import ProblemSolving
  • openTEPES_run(DirName=".../openTEPES", CaseName="9n") → DirName=".../openTEPES/cases" (CLI --dir likewise)

New: classical Benders

oT_Solver/Benders.lshaped() — master = vNetworkInvest only, subproblem = the full openTEPES model with each candidate
pinned via an explicit equality (mutable Param) and duals read through the dual Suffix. Validates on 9n: joint LP
252.201330 MEUR vs Benders 252.201345 MEUR in 8 iterations (rel err 5.78e-08, ~5 s). Acts as a compatibility guard
for the rest of the architecture restructure.

GitHub Action - CI matrix

3 → 7 tests in tests/test_run.py:

  • Single-stage (6): 9n, sSEP, 9n_PTDF, 9n_heat (heat sector), NG2030 (Nigeria), RTS-GMLC
  • Multi-stage (1): 9n7y — new case_multi_stage_7d_system fixture (one representative week per stage) — first CI
    coverage of the representative-stages pattern documented in doc/md/QA.md
  • Benders (1): convergence of lshaped on 9n vs joint LP
  • Inline feature-coverage matrix in the test file documents what each case validates (hydrogen sector + water
    reservoirs were already covered by sSEP; now visible)
  • RTS24 excluded; RTS-GMLC_6y deferred (>10 min
    multi-stage solve)

…shaped Benders + CI extension

  Layer 2 (oT_IO/):    openTEPES_InputSource.py (496 lines) -> Schema/Source/CSVSource/DuckDBSource (5 files)
  Layer 5 (oT_Solver/): openTEPES_ProblemSolving.py (304 lines) -> Persistent/Tuning/DualExtraction/ProblemSolving (4
  files)
                       + new Benders.py (classical L-shaped for transmission expansion)
  Layout:              all 9 case studies move to openTEPES/cases/<case>/

  BREAKING: clean break, no deprecation shim. External imports must update:
    from openTEPES.openTEPES_InputSource    -> openTEPES.oT_IO
    from openTEPES.openTEPES_ProblemSolving -> openTEPES.oT_Solver.ProblemSolving
    openTEPES_run(DirName='.../openTEPES', CaseName='9n') -> DirName='.../openTEPES/cases'

  CI matrix grows from 3 to 7 tests: 6 single-stage cases + 1 multi-stage (9n7y, first
  multi-stage coverage) + 1 Benders compatibility test (asserts L-shaped converges to
  joint-LP cost on 9n within 1e-4 relative tol). Inline coverage matrix in test_run.py
  documents which case validates which feature (sSEP -> hydrogen+reservoirs already covered).

  No behaviour change. 10/10 tests pass under HiGHS in 120 s. First PR of the layered-
  architecture restructure proposed in Docs/architecture/opentepes_architecture_proposal.md.
@erikfilias erikfilias self-assigned this May 28, 2026
@erikfilias erikfilias added the enhancement New feature or request label May 28, 2026
…VG to README

  The previous commit (35ab13a) moved every bundled case study to
  openTEPES/cases/ but only staged the new locations — the 420 files at
  the old openTEPES/<case>/ paths were left tracked in HEAD even though
  they had been physically removed from the working tree. This commit
  finishes the move by staging those deletions so the repository no
  longer carries duplicates.

  Also adds a new 'Architecture' section to README.md with the layered
  package diagram (doc/img/openTEPES_architecture.svg, copied from the
  RFC at Docs/architecture/opentepes_architecture_proposal.md) so new
  readers can see the six-layer model at a glance.
@erikfilias erikfilias requested a review from arght May 28, 2026 20:27
  Per maintainer preference: one src/ folder with the layer encoded in the
  filename (openTEPES_IO_*, openTEPES_Solver_*) instead of per-layer subfolders.
  Single src/__init__.py re-exports the full public surface. Pure rename — no
  logic change; all imports updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant