Skip to content

AgentiGrid: keep "};" on MATPOWER cell arrays so ExaGO reads genfuel - #137

Open
ahajdar wants to merge 2 commits into
ORNL:developfrom
ahajdar:amir/fix-genfuel-terminators
Open

ahajdar wants to merge 2 commits into
ORNL:developfrom
ahajdar:amir/fix-genfuel-terminators

Conversation

@ahajdar

@ahajdar ahajdar commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Merge request type

  • New feature
  • Resolves bug
  • Documentation
  • Other

Relates to

  • OPFLOW
  • SOPFLOW
  • SCOPFLOW
  • TCOPFLOW
  • CMake build system
  • Spack configuration
  • Manual
  • Web docs
  • Other (AgentiGrid)

This MR updates

  • Header files
  • Source code
  • CMake build system
  • Spack configuration
  • Web docs
  • Manual
  • Other (AgentiGrid tests and test fixture)

Summary

AgentiGrid's MATPOWER writer dropped the ; after cell arrays (mpc.genfuel = { ... } instead of ... };). ExaGO's reader (src/ps/psreaddata.cpp) ends mpc.genfuel at the first line containing };, so for every case AgentiGrid rewrote, ExaGO ignored the fuel types:

  • every unit took the default fuel;
  • ramp rates were 0, so SCOPFLOW could not redispatch in contingencies and reported local infeasibility on ACTIVSg200 at base load (the original file converges);
  • wind and solar units stayed at Pmin = Pmax.

The repository's own test data shows the bug: agentigrid/tests/fixtures/sample_opflow_output.txt (OPFLOW on AgentiGrid-rewritten ACTIVSg200) listed all 49 generators as COAL, while case_ACTIVSg200.m has 25 coal, 17 ng, 6 wind and 1 nuclear (bus 189), and the wind units had Pmin = Pmax. test_gen_189 asserted COAL.

Commit 1 — the fix:

  • agentigrid/parsers/matpower_parser.py keeps }; / ]; on cell-array sections; matpower_writer.py writes };, including for networks parsed before the fix.
  • New tests/grid_files/test_matpower_cell_terminators.py (3 tests) mimics ExaGO's genfuel detection on a round-tripped ACTIVSg200; all 3 fail without the fix.

Commit 2 — tests:

  • Regenerated tests/fixtures/sample_opflow_output.txt with the fixed writer (Ipopt 3.14.14); updated expected values in tests/results/test_opflow_parser.py (bus 189 NUCLEAR, 21 iterations, 0.021 s) and added test_fuel_mix_matches_case_file.
  • TestExecutorLive::test_opflow_run overwrote this tracked fixture on every run with an opflow binary, so the parser tests depended on the machine and test order (test_solve_time already failed against the committed fixture). It now writes the fixture only with AGENTIGRID_REGENERATE_FIXTURES=1, and the class skips without the binary, like TestMPIGuard. tests/README.md documents regeneration.
  • Entry in agentigrid/claude_code_changes.md.

Testing: python -m pytest -m "not slow" from agentigrid/ — 1083 passed, 13 skipped without ExaGO binaries (2 failures before this change). The file-naming check (buildsystem/tools/file_naming_conventions.pl) returns 0.

AI assistance: prepared with Claude (Anthropic); commits carry Co-Authored-By: Claude, and the change is logged in claude_code_changes.md.

Linked Issue(s)

None filed.

ahajdar and others added 2 commits October 3, 2026 21:25
The MATPOWER parser stored mpc.gentype / mpc.genfuel / mpc.bus_name without
the trailing ";", and the writer wrote them back as a bare "}". ExaGO's reader
(src/ps/psreaddata.cpp) ends mpc.genfuel at the first line containing "};", so
for every case AgentiGrid rewrote, ExaGO ignored the fuel types: all units fell
back to the default fuel, ramp rates stayed 0 (SCOPFLOW cannot redispatch in
contingencies and reports local infeasibility on ACTIVSg200 at base load, where
the original file converges) and wind/solar units stayed at Pmin = Pmax.

The parser now keeps "};" / "];"; the writer also terminates raw sections from
networks parsed before this fix. tests/grid_files/test_matpower_cell_terminators.py
mimics ExaGO's genfuel detection on a round-tripped ACTIVSg200 (3 tests; all
fail without the fix).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…onger overwrites it

tests/fixtures/sample_opflow_output.txt is OPFLOW output for case_ACTIVSg200.m
as rewritten by AgentiGrid. It was produced by the writer fixed in the previous
commit and therefore listed all 49 generators as COAL; test_gen_189 asserted
COAL although the case file says nuclear for bus 189. Regenerated with the
fixed writer (25 coal, 17 ng, 6 wind, 1 nuclear) and updated the expected
values in tests/results/test_opflow_parser.py; test_fuel_mix_matches_case_file
guards against regenerating it with a broken writer again.

TestExecutorLive::test_opflow_run overwrote this tracked fixture on every run
with an opflow binary, so the parser tests depended on the machine and test
order (test_solve_time already failed against the committed fixture). It now
writes the fixture only with AGENTIGRID_REGENERATE_FIXTURES=1, and the class
skips without the binary like TestMPIGuard. tests/README.md documents the
regeneration; claude_code_changes.md has the entry for both commits.

Fast suite without ExaGO binaries: 1083 passed, 13 skipped (before: 2 failed).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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