Repository navigation
Conversation
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]>
…s without opflow 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 now skips without the opflow binary, like TestMPIGuard. (Develop already stopped the live test from overwriting the fixture in #147.) tests/README.md describes the fixture; claude_code_changes.md has the entry for both commits. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd trips Five defects found while specifying the parser and writer: 1. Rows with a non-numeric value were skipped with only a log warning, so a bus, generator or branch could silently disappear; too-short rows crashed with IndexError. Known sections (bus, gen, branch, gencost) now raise ValueError naming the section and row for non-numeric values, column counts outside the section's limits, and non-integral values in integer columns. 2. Valid MATLAB syntax was misread: two rows on one line became one garbage row and comma-separated rows were all dropped. These, '...' continuations, unterminated blocks and a missing mpc.bus now raise ValueError. 3. The writer crashed on Inf/NaN, which the reader accepts. They are written as Inf/-Inf/NaN; bus solution columns no longer lose precision to .4f. 4. Every read/write round trip added another "MATPOWER Case Format" header line. Writing is now idempotent. 5. Case version '1' was accepted although ExaGO reads version 2; it now raises. A missing version still means '2'. CRLF input is normalised on read and output is always LF. The function line always carries network.casename. All 29 case files in datafiles/ still parse and round-trip to equivalent networks. New tests/grid_files/test_matpower_hardening.py (29 tests, 22 fail without the fix). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rounding, baseMVA literals Three defects found by property-based round-trip testing: 1. A finite value near the float maximum was written with 10 significant digits that round past it and read back as Inf. The writer now falls back to the exact representation when rounding overflows. 2. A value that rounds to an integer (e.g. 9999999999.5) was written as "1e+10" the first time and "10000000000" after re-reading, so writing was not idempotent. The integer form is now decided on the rounded value. 3. mpc.baseMVA was read with a digits-and-dots pattern: "1e2" (and "1e+15", which the writer itself emits for large values) was silently read as 1, and a negative value was reported as missing. Any numeric literal (sign, exponent, Inf/NaN) on an mpc.baseMVA line is now accepted, text in comments is ignored, and a non-numeric value raises ValueError. 18 more tests in tests/grid_files/test_matpower_hardening.py (12 fail without the fix). All 29 case files in datafiles/ still round-trip. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 of 20 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces #137 (fork PR, closed so CI can run).
Merge request type
Relates to
This MR updates
Summary
AgentiGrid's MATPOWER writer dropped the
;after cell arrays (mpc.genfuel = { ... }instead of... };). ExaGO's reader (src/ps/psreaddata.cpp) endsmpc.genfuelat the first line containing};, so for every case AgentiGrid rewrote, ExaGO ignored the fuel types: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, whilecase_ACTIVSg200.mhas 25 coal, 17 ng, 6 wind and 1 nuclear (bus 189), and the wind units had Pmin = Pmax.test_gen_189asserted COAL.Commit 1 — the fix:
agentigrid/parsers/matpower_parser.pykeeps};/];on cell-array sections;matpower_writer.pywrites};, including for networks parsed before the fix.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:
tests/fixtures/sample_opflow_output.txtwith the fixed writer (Ipopt 3.14.14); updated expected values intests/results/test_opflow_parser.py(bus 189 NUCLEAR, 21 iterations, 0.021 s) and addedtest_fuel_mix_matches_case_file.TestExecutorLive::test_opflow_runoverwrote this tracked fixture on every run with anopflowbinary, so the parser tests depended on the machine and test order (test_solve_timealready failed against the committed fixture). It now writes the fixture only withAGENTIGRID_REGENERATE_FIXTURES=1, and the class skips without the binary, likeTestMPIGuard.tests/README.mddocuments regeneration.agentigrid/claude_code_changes.md.Testing:
python -m pytest -m "not slow"fromagentigrid/— 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 inclaude_code_changes.md.Linked Issue(s)
None filed.