Skip to content

Read startup/shutdown power capability from PowerIO's typed rows - #4

Closed
samtalki wants to merge 6 commits into
feat/powerio-0.9-and-upstream-mergefrom
v09/powerio-0.9-followups
Closed

samtalki wants to merge 6 commits into
feat/powerio-0.9-and-upstream-mergefrom
v09/powerio-0.9-followups

Conversation

@samtalki

@samtalki samtalki commented Aug 18, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #3. It is one commit on top of that PR's head, and it merges only after it.

#3 left five raw dictionary reads in parse_sc_data and scoped them out as post 1.0 work: goc3_shutdown_power_cap and the T_supc_pr / T_supc_cs / T_sdpc_pr / T_sdpc_cs comprehensions still went to data.sdd_lookup and data.sdd_ts_lookup for the startup and shutdown power capability, and re-derived the producer/consumer split from the uid string with is_pr. Nothing about that has to wait for 1.0. PowerIO 0.9.0's SddRow already carries all four fields, and sc_data.prod / sc_data.cons already carry PowerIO's own device_type split with this file's stacked indices spliced onto it by the remap two functions above. No new PowerIO API is needed, so the refactor is available today.

What changes

All five now iterate sc_data.prod / sc_data.cons:

Was Is
val["initial_status"]["p"] p.p_0
val["p_shutdown_ramp_ub"] p.p_rd_sd
val["p_startup_ramp_ub"] p.p_ru_su
data.sdd_ts_lookup[key]["p_lb"] p.p_min
_uidnum(val["uid"]) + 1, get_j_prcs(val["uid"], …) p.j_prcs
is_pr(val["uid"], …) PowerIO's device_type split

goc3_shutdown_power_cap takes the two row vectors plus periods and dt instead of the whole parsed document. It is internal, so the signature change reaches nothing outside this file. The is_pr(::String, …) overload has no callers left and is removed; the Int overload that save_go3_solution uses stays.

Equivalence

parse_sc_data on C3E4N00073D1_scenario_303, 5318ac1 against this commit, same local PowerIO 0.9.0 and the same compiled C library. All 54 fields it returns are byte identical, compared as SHA256 over their serialized form, and so are lengths and producers_first.

The eight sums this touches reach the model only through prarray and csarray, so they were also read back off those rows individually:

Sum rows nonzero bit identical
sum_T_supc_pr 2772 40 yes
sum2_T_supc_pr 2772 40 yes
sum_T_sdpc_pr 2772 12 yes
sum2_T_sdpc_pr 2772 12 yes
sum_T_supc_cs 918 0 yes
sum2_T_supc_cs 918 0 yes
sum_T_sdpc_cs 918 0 yes
sum2_T_sdpc_cs 918 0 yes

Every consumer sum is zero on this scenario, in both versions, so equal values alone say nothing about the two consumer branches. The splits were compared directly instead: across all 205 devices the removed is_pr regex classification and PowerIO's device_type agree exactly, 154 producers and 51 consumers. j_prcs is distinct across all 205, so the p_sdpc writes do not collide here.

Test slices, both green against local PowerIO 0.9.0:

  • EMP_TEST_SELECTION=goc3 — 750 tests, 11m35s
  • EMP_TEST_SELECTION=nothing — 2583 tests, 4m04s

The uid indexing weakness this does not fix

is_pr, get_j_pr, get_j_cs and get_j_prcs still take every stacked index from a regex match on the uid string, so two devices whose uids share a numeric substring land on one index. On the GOCompetition 14 bus file vendored as powerio-prob's own test fixture, is_pr misclassifies 7 of 17 devices by device type, and get_j_prcs puts two devices in one slot four times, which would overwrite one device's p_sdpc entries with another's. PowerIO.goc3_scopf_data warns on that file that the two device classes do not form disjoint contiguous uid blocks. C3E4N00073D1 uses zero padded, class disjoint uids, so the suite gives no signal either way.

PowerIO.goc3_scopf_data, the only SCOPF surface this file calls, does not index by document order: its rows come out sorted by uid number and its sdd_ids_producer / sdd_ids_consumer are a lexicographic string sort, so it offers no scheme to adopt. powerio-prob's ScopfInstance does implement and test document order indexing, reachable through PowerIO.parse_scopf, which this file does not use. Fixing it here needs either a typed Julia binding to that instance or a rewrite of this file's whole index scheme.

Before merging

Merge after #3, which itself waits on PowerIO.jl 0.9.0 registering in General.

🤖 Generated with Claude Code

@samtalki
samtalki force-pushed the v09/powerio-0.9-followups branch from 301fbf6 to 5f7fa18 Compare August 18, 2026 20:23
…ccepted

MATPOWER, PSS/E and PowerWorld all read `rate_a = 0` as an unrated branch, and
real cases lean on it: every arc of stock case14, case57, case118 and
case13659pegase, 4924 of 25412 in case_ACTIVSg10k, 44104 of 208242 in
case_SyntheticUSA. Nine of the twenty four MATPOWER cases in the powerio test
corpus carry at least one. Read literally, the rating became a bound of exactly
zero on the flow and a thermal limit of `p^2 + q^2 <= 0`, so stock case14 came
back INFEASIBLE_PROBLEM_DETECTED instead of solved.

An unrated branch now gets an infinite flow bound and an infinite upper bound on
its thermal limit rows. The rating stays inside the thermal expression rather
than being replaced by infinity there, so the residual and its derivatives stay
finite. case14, case57 and case118 now solve and agree with PowerModels/Ipopt to
4.2e-11, 1.4e-12 and 1.5e-13 relative. Rated cases are untouched: their bounds
are the rating and their thermal upper bound is zero, exactly as before.

The README said nothing about which case files the package reads, and imported
GOC3Benchmark, which has not been a dependency since the GOC3 parser moved to
PowerIO. It now names the formats, the `from` keyword for the ones an extension
cannot identify, the PGLib-OPF name lookup, and the MW convention on the .Pd and
.Qd files. `from` is documented on opf_args, opf_model and mpopf_model.
The wrapper forwards T as a keyword, so its inference stays unresolved even
once PowerIO pins its return type; only a positional `::Type{T}` method
resolves it. Asserting both separates the two halves: the PowerIO assertion
flips as soon as the library is fixed, the wrapper assertion flips when the
call site here follows.
@samtalki
samtalki force-pushed the v09/powerio-0.9-followups branch from 5f7fa18 to 424054e Compare August 19, 2026 18:23
samtalki and others added 4 commits August 20, 2026 13:22
PowerIO 0.9 carries document order ordinals on the SCOPF instance rows, `j_dev` within the device class and `j_sdd` in the canonical producers then consumers stacking, and the initial on status on the device, ac line and transformer rows. Every index this package derived from a uid string is now a field read: `_uidnum`, `get_j_pr`, `get_j_cs`, `get_j_prcs`, `is_pr` and the `producers_first` threading are deleted, the stacked variable numbering is arithmetic on the ordinals, and the rows that reference a device from another table (energy windows, price blocks) map through per class dictionaries built from the instance rows.

The suffix rule read the digits in a uid as the device's position in its class, so any file that does not follow the competition uid convention was misindexed, including GOC's own 14 bus validation case; PowerIO warned and continued. On C3E4N00073D1_scenario_303 the two agree everywhere: no row differs across 154 producers, 51 consumers, the active reserve set rows, 105 ac lines, 15 transformers, 1 dc line and 73 buses.

`parse_sc_data` takes the GOC3 document text and returns the data and the lengths. `goc3_scopf_data` types PowerIO's parse of it, so the periods and the interval durations come off the instance instead of a second raw parse, and the three `goc3_add_status_flags!` calls take typed rows in place of the raw lookup dictionaries.

`save_go3_solution` takes the case file, rebuilds the uid to index tables from the instance and maps every solution row through them. Its old signature could not be called: it asked for `producers_first`, which `goc3_model` never returned, and it had no call sites.

Renaming every uid in the case and the unit commitment document, so the digits the retired rule would have read run in reverse of document order, must move neither the model nor the written solution. The regression asserts both: same variable count, same objective and constraints at x0, and every written field equal to the rename of the original, uid for uid.

Verified against PowerIO on the companion `v09/scopf-instance-consumers` branch: the goc3 slice and the full suite pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
PowerIO's `T` keyword is a value of an abstract `Type{<:Real}`, so forwarding the wrapper's static parameter through it dropped the specialization: the result inferred as an unparameterized NamedTuple and every field read off it widened to `AbstractArray{BusRow{T}} where T`. Forwarding positionally keeps the static parameter, which is what the wrapper's own comment says its `::Type{T}` signature exists for.

Both inference assertions now hold and stop being broken. PowerIO 0.9 pins its own return type, which flips the first, and this call site follows it, which is what the second was waiting on. A single abstract field in the parse leaves `ExaModel(CORE, data)` unresolved under `--trim=safe`, so the assertions are the guard against that regressing.

EMP_TEST_SELECTION=all: 6713 passed, 0 failed, 0 broken, 13m39s.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Pass the element type positionally through every PowerIO parse and load series call so the multiperiod argument function has one exact inferred return type. Restrict PGLib fallback resolution to bare case names, and run the compiled library check as a self-contained CI slice with a private output directory.
`parse_file(BalancedNetwork, ...)` returns the concrete network type rather
than one inferred from the call, and `Val(:live)` selects the method that
keeps the handle out of the AOT call graph. Every parse and LoadSeries route
takes both, so the row element types stay isbits and `ExaModel(CORE, data)`
resolves under `--trim=safe`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@samtalki
samtalki deleted the branch feat/powerio-0.9-and-upstream-merge October 26, 2026 17:17
@samtalki samtalki closed this Oct 26, 2026
@samtalki
samtalki deleted the v09/powerio-0.9-followups branch October 26, 2026 17:17
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