Skip to content

Read GOC3 through PowerIO's AcScucInstance - #69

Merged
sshin23 merged 1 commit into
madsuite-org:mainfrom
samtalki:powerio-0.11-goc3
Oct 27, 2026
Merged

sshin23 merged 1 commit into
madsuite-org:mainfrom
samtalki:powerio-0.11-goc3

Conversation

@samtalki

Copy link
Copy Markdown
Contributor

The GOC3 security-constrained model reads its problem file through PowerIO.jl's AcScucInstance, replacing about 1,200 lines of hand-written JSON handling. GOC3 parsing goes from 1,215 to 529 lines. This is the GOC3 half of the PowerIO migration (#60 did both, against PowerIO 0.9). It is independent of #68 and needs only the registered PowerIO 0.11.6.

Why

  • Indexing from uid digits: every index came from the digits of a uid (match(r"\d+", uid)): buses, devices, branches, reserve zones, contingencies, and the producers/consumers split (producers_first). A file that doesn't follow the competition's uid convention was silently misindexed.
  • Silent misalignment: a UC file missing a row shifted every later row.

What changes

  • goc3_static(filename) (goc3_parser.jl):
    • parses the problem with PowerIO.parse and checks that it is an AcScucInstance;
    • reads buses, lines, transformers, DC lines, shunts and devices from instance.network, and time series, reserve zones, contingencies and violation costs from instance.inputs;
    • gives every element its position by enumerating its table. Nothing reads a uid's spelling, and producers_first is gone.
  • goc3_commitment joins the UC solution file by uid, and throws if the file lacks an element.
  • parse_sc_data (sc_parser.jl) builds the same arrays goc3.jl reads, with the same names and shapes. Rows no longer carry uid strings, so every array is isbits; the uids travel on the host as sc_data_array.uids.
  • goc3_model keeps its signature and return. lengths is a NamedTuple with the same 18 names in the same order, so positional destructuring still works.
  • save_go3_solution(uc_filename, solution_name, result, vars, lengths, uids) takes the uid table as its sixth argument, where it took producers_first. It is unexported and nothing in the package called it.

Equivalence

On C3E4N00073D1_scenario_303, I built both models: the old parser loaded from main, and the new one. On CPU, in Float64:

  • nvar, ncon, nnzj, nnzh are equal: 140544, 152244, 466744, 161982.
  • x0, lvar, uvar, lcon and ucon are identical once the contingency and cmax38 rows, which the old code emitted in Dict order, are permuted.
  • Objective, gradient and Jacobian are identical at x0 and at a random point.
  • Constraints agree to 1.1e-15 relative. The differences come from summation order in the reserve balances, and from consumers' initial power, which PowerIO carries in MW (at most 4.4e-16).
  • The solution file written from the same point is identical, uid for uid.

Tests

The goc3 slice passes locally, 80/80. It now:

  • pins nvar, ncon, and the objective and Σ|cons| at x0 and at a perturbed point, at the values the old parser gives;
  • checks that every array the model reads is isbits;
  • checks that the model doesn't depend on how the document spells uids or orders tables, as Use PowerIO 0.9 for case and GOC3 parsing #60's test did:
    • renaming every uid (digits running against document order) gives the same model and the same solution rows under the new names;
    • reversing every table (consumers first) gives the same model with its rows reordered.

Known gaps in PowerIO 0.11.6 (none affect this model)

  • A device's initial active power is available only in MW, with a consumer's sign dropped. GOC3 consumers have p ≥ 0.
  • A line's additional terminal shunt is recovered by subtracting half the charging from PowerIO's merged terminal susceptance.
  • Devices and shunts name no bus in ScucInputs, so they are joined to the network's generator, load and shunt rows by uid.

Each is exact on the test case. A signed per-unit initial power and a bus id on PowerIO's device and shunt rows would remove all three; I'll raise them with PowerIO.

🤖 Generated with Claude Code

The GOC3 security-constrained model read its problem file with ~1,200 lines
of hand-written JSON handling, and took every index -- buses, devices,
branches, reserve zones, contingencies, and the producers/consumers split --
from the digits of each uid, so a file that does not follow the competition's
uid convention was silently misindexed. PowerIO 0.11 reads a GOC3 problem as
an `AcScucInstance`: its `network` holds the buses, branches, devices, shunts
and DC lines, and its typed `inputs` the device time series, reserve zones,
contingencies and violation costs, all in document order.

- `goc3_static` (goc3_parser.jl) reads the problem through PowerIO and gives
  every element its position by enumeration; nothing reads a uid's spelling,
  and `producers_first` is gone.
- `goc3_commitment` joins the UC solution file by uid and refuses an element
  the file lacks, where a missing row used to shift every later row.
- `parse_sc_data` (sc_parser.jl) builds the same time-indexed arrays from
  those tables. Rows carry no uid strings, so every array is isbits; the uids
  travel on the host as `sc_data_array.uids`.
- `save_go3_solution(uc_filename, solution_name, result, vars, lengths, uids)`
  takes that table where it took `producers_first`.
- `lengths` is a NamedTuple with the same 18 names in the same order.

On C3E4N00073D1_scenario_303 the model is the one the old parser built:
equal nvar, ncon, nnzj and nnzh, identical start and bounds, identical
objective, gradient and Jacobian at x0 and at a random point, constraints
equal to 1.1e-15 relative (summation order in the reserve balances, and
consumers' initial power, which PowerIO carries in MW), and the same
solution file. The tests pin those numbers, and check that renaming every
uid, or reversing every table, leaves the model unchanged.

GOC3 parsing goes from 1,215 to 529 lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sshin23
sshin23 merged commit b3af8ef into madsuite-org:main Oct 27, 2026
5 checks passed
@sshin23

sshin23 commented Oct 27, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution @samtalki!

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.

2 participants