Skip to content

Fill event models from the emulator's system at simulation build - #1700

Draft
m-bossart wants to merge 1 commit into
psy6from
mb/event-lookup-by-key
Draft

m-bossart wants to merge 1 commit into
psy6from
mb/event-lookup-by-key

Conversation

@m-bossart

@m-bossart m-bossart commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Draft until Sienna-Platform/PowerOperationsModels.jl#404 merges. This PR uses it, and [sources] pulls POM from main, so CI fails until then.

Fixes #1701.

Each model's build filled the shared event models from its own system.
The outages the emulator applied therefore depended on build order, and their attribute ids could belong to a decision model's system, so the emulator could crash or apply the wrong outage.

The emulator's system is now the single source of truth for which outages exist:

  • Before any model builds, the simulation fills every event model from the emulator's system with POM's discover_event_attribute_device_map.
    Each model then applies the event to the outaged devices it has.
  • A sequence with events and no emulation model fails the build with IS.ConflictingInputsError.
  • apply_simulation_events! looks attributes up in the emulator's system by id, as before, and fails loudly if one is not of the event model's type.
  • Outage attributes in a decision model's own system do not affect events.
    They may serve other formulations, such as security-constrained N-1 in a UC → RT → emulator setup.

An outaged device no longer has to be in any decision model:

  • Event-parameter state starts at its no-outage values (countdown and offsets 0, availability 1) instead of NaN, since the emulator reads its event parameters from decision state before any event step writes them.
  • Event-parameter keys only the emulator has get a decision state of their own.
  • The writers that reset an outaged device's variables (OnVariable, ActivePowerVariable, TimeDurationOn/Off) skip a device whose variable state no model writes.

Tests (test/test_events.jl):

  • The diverging-id reproduction from Regression on psy6: simulation events look up outages by attribute id across systems #1701 runs to completion with the expected outages.
  • The emulator outages Alta and Park City while D1's system carries its own Brighton outage: both decision models get event parameters for exactly Alta and Park City, and D2 sees Park City unavailable with zero dispatch during the outage.
  • An outage on a device only the emulator has is applied by the emulator and leaves the decision models alone, while a shared device's outage still reaches them; the same holds when no decision model has event parameters for the device type.
  • A sequence with events and no emulator fails the build.
  • With rebuild_model = true on every model, the simulation runs to completion.

The full suite passes except test_market_bid_cost.jl:388 (2 failures), which also fail without this change.

🤖 Generated with Claude Code

Each model's build used to fill the shared event models from its own
system, so the map the emulator applied at runtime depended on build
order, and its attribute ids could belong to a decision model's system.

The emulator's system is the single source of truth for which outages
exist. Before building any model, the simulation now fills every event
model from the emulator's system with POM's
discover_event_attribute_device_map; each model then applies the event
to the outaged devices it has. A sequence with events and no emulation
model fails the build with IS.ConflictingInputsError. Outage attributes
in a decision model's own system do not affect events; they may serve
other formulations, such as security-constrained ones.
apply_simulation_events! looks the attributes up in the emulator's
system by id and checks each has the event model's type.

Because the outaged devices now come from the emulator's system, an
outaged device may be one no decision model has. Event-parameter state
starts at its no-outage values instead of NaN, since the emulator reads
its event parameters from the decision state before any event step has
written them. Event-parameter keys only the emulator has get a decision
state of their own, and the event-path variable writers skip an outaged
device whose variable state no model writes.
@m-bossart
m-bossart force-pushed the mb/event-lookup-by-key branch from 950a0a7 to 8725973 Compare October 17, 2026 00:54
@m-bossart m-bossart changed the title Apply simulation events from the emulator's outages, matched by key Fill event models from the emulator's system at simulation build Oct 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant