Skip to content

Fix 1D container creation ahead of IOM issue #15 assertion#174

Open
luke-kiernan wants to merge 1 commit into
mainfrom
lk/issue-15-1d-containers
Open

Fix 1D container creation ahead of IOM issue #15 assertion#174
luke-kiernan wants to merge 1 commit into
mainfrom
lk/issue-15-1d-containers

Conversation

@luke-kiernan

Copy link
Copy Markdown
Collaborator

Summary

IOM is adding a runtime assertion (Sienna-Platform/InfrastructureOptimizationModels.jl#137, tracking Sienna-Platform/InfrastructureOptimizationModels.jl#15) that rejects any variable/constraint/expression/dual/parameter container built with only one index axis — containers must always be indexable as x[i, j]. This proactively fixes every call site in POM that currently builds such a 1D container, so nothing breaks once that assertion lands.

Three patterns, fixed consistently:

  • End-of-horizon / initial-condition snapshots (thermal_generation.jl ActiveRangeICConstraint, hydro_generation.jl ReservoirLevelTargetConstraint, storage_models.jl StateofChargeTargetConstraint): built with just a names axis but indexed with an extra time key downstream. Added the matching singleton time axis ([time_steps[end]] / [1]).
  • Whole-horizon budget constraints (hydro_generation.jl EnergyBudgetConstraint/WaterBudgetConstraint, source.jl ImportExportBudgetConstraint): aggregate over the entire horizon with no time axis by design. Added a ["horizon"] singleton axis, consistent across all budget sites.
  • Genuinely system-wide scalars (agc.jl SteadyStateFrequencyDeviation variable + FrequencyResponseConstraint): added a ["System"] singleton axis.

Also fixes 4 latent bugs in storage_models.jl (StorageCyclingCharge/StorageCyclingDischarge, marked # no test coverage) that built a 1D container but were already being indexed with 2 keys (constraint[name, time_steps[end]]) downstream — that would already error today against a 1D DenseAxisArray.

Test plan

  • All 5 changed files parse cleanly (Meta.parseall)
  • Formatter clean
  • Full test suite — could not run: main currently fails to precompile (TypeError in NetworkModel/AbstractNetworkModel, common_models/add_expressions.jl:10), a pre-existing, unrelated breakage someone else is already fixing. Confirmed by reproducing the identical failure with these changes fully reverted. Recommend re-running CI on this branch once that's resolved.

🤖 Generated with Claude Code

IOM is adding a runtime check that rejects any variable/constraint
container built with only one index axis. Proactively fixes every
POM call site that would trip it:

- Storage/hydro/thermal end-of-horizon and initial-condition
  constraints built with just a names axis but indexed with an
  extra time key; adds the matching singleton time axis
  ([time_steps[end]] / [1]).
- Whole-horizon budget constraints (hydro energy/water budget,
  source import/export) that have no time axis by design; adds a
  ["horizon"] singleton axis.
- The AGC steady-state frequency deviation variable/constraint,
  which are genuinely system-wide scalars; adds a ["System"]
  singleton axis.
- Also fixes 4 latent bugs in storage_models.jl (StorageCyclingCharge/
  Discharge, no test coverage) that built a 1D container but were
  already being indexed with 2 keys downstream.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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