Skip to content

indflex: Python toolkit for the full chain (process models → PSI → D3R → VPP) - #1

Merged
ruikelyu merged 7 commits into
mainfrom
python-port
Nov 8, 2026
Merged

ruikelyu merged 7 commits into
mainfrom
python-port

Conversation

@ruikelyu

@ruikelyu ruikelyu commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Summary

Turns this repository into indflex, Industrial demand flexibility: from process models to grid decisions: a Python package with one teaching notebook per step of the thesis chain. The original MATLAB folders are unchanged.

Step What Notebook Solver
1 STN / LSTN (continuous processes) 01_stn_vs_lstn HiGHS
1 RTN / cRTN (batch processes) 02_rtn_vs_crtn HiGHS
2 PSI: parameter identification from meter data 03_psi Gurobi
3 D3R: dimension reduction (adjustable load fleet) 04_d3r HiGHS
4 VPP: regulation bidding and merit-order disaggregation 05_vpp HiGHS
  • Package src/indflex/: Pyomo models with HiGHS as the default solver (Gurobi optional), plain-text data under data/.
  • Checked against the original MATLAB code: STN/LSTN, RTN/cRTN and VPP results match the paper code exactly. PSI and D3R are checked against the paper repos' saved datasets and results. Fixtures and the scripts that regenerate them are in tests/fixtures and tools/.
  • Docs: one concept page per step in docs/, plus docs/notes_on_paper_code.md with differences found in the original paper code.
  • README rewritten around the chain; CITATION.cff added.

After merging, the repository can be renamed to indflex. GitHub redirects the old URL.

Test plan

  • pytest: 42 tests pass locally (Gurobi tests are skipped without a full license)
  • All five notebooks execute without errors (jupyter nbconvert --execute)
  • README quickstart code runs; all relative links in README and docs/ resolve
  • GitHub Actions tests workflow (HiGHS only) passes on this PR

🤖 Generated with Claude Code

ruikelyu and others added 7 commits November 7, 2026 21:16
- indflex package (Pyomo + free HiGHS solver, Gurobi optional): STN, LSTN,
  and multi-factory fleet models, data loaders, solver wrapper, plots
- Legacy .xlsx/.mat inputs converted to plain YAML/CSV under data/
- Tests check the Python models against reference outputs from the
  original MATLAB/YALMIP code (tools/matlab_reference/make_reference.m)
- Notebook 01: interactive STN schedule, STN vs LSTN accuracy over July
  2022, and a scaling demo where each solve takes at most 30 s
- README quickstart and GitHub Actions test workflow; MATLAB folders unchanged

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- indflex.models.batch: conventional RTN with flexible EAF (Zhang et al.
  2017) and the continuous RTN (cRTN), transcribed from
  Efficient-Scheduling-of-Discrete-Industrial-Processes
- Batch plant data (steelmaking_zhang2017, eaf_small_case) as YAML
- Tests compare against MATLAB/Gurobi references generated by
  tools/matlab_reference/make_reference_crtn.m; documents a bug in the
  MATLAB RTN with one heat (sum over time instead of over heats)
- Notebook 02: rounding error in the one-furnace case, interactive
  steelmaking schedules, binaries vs. heats, and a HiGHS solve-time sweep
  sized to finish in about 2 minutes
- solve(): Gurobi via gurobipy as an option, unfixed variable counts,
  energy units; viz: sub-hourly slots and generic scaling plots

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- indflex.identify: mSTN forward model, one-day inverse problem (primal,
  dual, strong duality; Gurobi NonConvex), and the iterative training loop,
  transcribed from Production-Scheduling-Identification
- make_meter_dataset reproduces the paper's cement meter data exactly from
  the toolkit's STN
- target_from_energy: production-target prior from daily energy and public
  g; avoids the trivial zero-production solution under short time limits
- Notebook 03: one inverse solve recovers a 2-machine plant's rated powers
  and targets; iteration and the cement case are optional cells
- Tests: dataset parity with the paper fixtures, target prior, toy
  identification (skipped without a full Gurobi license)
- build_notebooks.py can rebuild selected notebooks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- indflex.reduce: adjustable load fleet (ALF) model, inverse problem with
  big-M KKT (L2 for Gurobi, L1 as a MILP for free HiGHS), iterative
  training as in Data-Driven-Dimension-Reduction, the paper's error metric
- Tests: ALF reproduces the paper's saved steel powder and steelmaking
  responses; single-solve fit on cement; integer meter data
- Notebook 04: one HiGHS solve fits a 1-load ALF to the cement STN
  (9.3% held-out error, paper 8.9%), power-band and fit figures
- Notebook 02: RTN rounding error vs cRTN melting progress, 8 per-heat RTN
  lines vs 4 shared cRTN lines, heat Gantt charts (heat_schedule,
  crtn_progress, viz.plot_gantt)
- Notebook 03: buffered 2-machine toy, machine schedules and buffer level,
  demand-response event figure

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…igures

- indflex.coordinate.vpp: standardized resource model, scenario-based
  bidding LP (day-ahead and real-time re-bid, HiGHS), duals as stored-energy
  values, merit-order disaggregation, one-hour signal simulation; ported from
  Real-time-operation-strategy-of-virtual-power-plants (Applied Energy 2024)
- Tests match the paper code: profits, bids, duals, and allocations over the
  first 2 minutes; merit order equals the disaggregation LP; eta^T lambda
  (default) is never costlier than the paper code's eta lambda
- Day-21 case converted to data/vpp (JSON + RegD CSV)
- Notebook 05: resource mix, hourly bids, merit order, signal following
- Notebook 02: 8-hour horizon so both RTN deliveries show; cRTN column at
  half height; optional RTN tie_break (cost reported without it)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- README: chain diagram, notebook table (runtime, solver), quickstart covering
  all four steps, papers/code/videos table, updated Chinese section
- docs/: one concept page per step (idea, limits, figures, results checked
  against the paper code, links) and reproducibility notes on the paper code
- CITATION.cff with the toolkit and the five papers
- tools: export_doc_figures.py, extract_paper_fixtures.py, and the VPP
  MATLAB reference script, so every figure and fixture can be regenerated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- README, CITATION.cff, pyproject.toml, package docstring: name indflex,
  tagline "Industrial demand flexibility: from process models to grid
  decisions", new repository URL (formerly Industrial User Modeling Toolkit)
- pyproject: keywords and project URLs
- test_psi: identify the toy plant with one inverse solve to optimality
  instead of time-limited iterations, whose outcome depended on machine load

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Nov 8, 2026

Copy link
Copy Markdown

Sorry @ruikelyu, your pull request is larger than the review limit of 150,000 diff characters

@ruikelyu
ruikelyu merged commit e34cf60 into main Nov 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant