Skip to content

Phase A+B: TransmissionInterface merge + ORDC cost-expression fold (stacked on #206) - #207

Merged
rodrigomha merged 5 commits into
rh/dev_refactor_servicesfrom
rh/dev_refactor_services_pt2
Jul 30, 2026
Merged

Phase A+B: TransmissionInterface merge + ORDC cost-expression fold (stacked on #206)#207
rodrigomha merged 5 commits into
rh/dev_refactor_servicesfrom
rh/dev_refactor_services_pt2

Conversation

@rodrigomha

Copy link
Copy Markdown
Contributor

Summary

Stacked on top of PR #206 (base branch is rh/dev_refactor_services, not main) — review/merge #206 first. Continues the per-type merged-container migration for the two service families #206 left on the service-name-as-meta pattern.

Phase A — TransmissionInterface

  • InterfaceFlowSlackUp/Down → one dense (interface_name, time) container per type, built once over all interfaces, empty meta (was per-interface meta = name). This also closes the use_slacks-on-ServiceModel gap (moved to the vector-axis builder reserves already use), so that path is now testable.
  • Min/MaxInterfaceFlowLimitParameter → merged per-type container (empty meta); the VariableMax InterfaceFlowLimit reads them 3-arg.
  • InterfaceTotalFlow (already name-keyed) and InterfaceFlowLimit (meta = "ub"/"lb" = direction) unchanged.
  • The no-contributing-devices loud error now covers interfaces too (no available contributing branches), merged into one check guarded by !(service_type <: PSY.ConstantReserveGroup).
  • Tests: merged slack shape + penalty wiring, merged param shape, no-contributing-branch error. Branch→interface mapping + aggregation verified by smoke test. No IOM changes.

Phase B — ORDC cost expression

  • ProductionCostExpression for ORDC (StepwiseCostReserve) folded from per-service meta = name into one dense (service, time) container per service type, empty meta — same shape as the device ProductionCostExpression. Read/write is now 3-arg.

Deferred to Phase C (pt3 branch, later)

The ORDC block-offer variables/constraints are already 3D (service, segment, time) merged. The ORDC slope/breakpoint PWL params stay on meta for now — merging them needs a shared/padded tranche axis and is coupled with the delta-PWL machinery, so they land with the 4D per-device AS-offer work in Phase C.

Reviewer notes

  • Comments tagged DELETE-AFTER-REVIEW are before/after container-change context for reviewers; remove on approval (grep -rn "DELETE-AFTER-REVIEW").
  • The psy6 / HiGHS-1.24-HVDC-MILP / IOM-rh/dev_service_refactor notes from Per-type service models with merged sparse/dense reserve containers #206 carry over unchanged; this branch adds no new dependency changes.
  • Full suite green (105446/105446, ~3m16s); the service test file timing is flat (no slowdown).

Opening as draft, stacked into #206.

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Continues the per-type merged-container migration introduced in #206 by consolidating TransmissionInterface slack/parameter containers and folding ORDC (StepwiseCostReserve) ProductionCostExpression into a single dense per-type container, while adding tests that exercise the previously untestable use_slacks ServiceModel path for interfaces.

Changes:

  • Build TransmissionInterface slack variables as one dense (interface_name, time) container per slack type (empty meta), and wire per-interface violation penalties into the objective.
  • Merge Min/MaxInterfaceFlowLimitParameter into per-type containers (empty meta) and update VariableMaxInterfaceFlow constraints to read them without per-service meta.
  • Fold ORDC ProductionCostExpression into one dense (service_name, time) container per reserve service type (empty meta), updating expression creation and reads accordingly; expand coverage with new interface-focused tests and broaden the “no available contributing devices/branches” error to include interfaces (while exempting ConstantReserveGroup).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/test_services_constructor.jl Adds regression tests for merged interface slacks/params and for the new “no contributing branches” error behavior.
src/services_models/transmission_interface.jl Updates VariableMaxInterfaceFlow constraint construction to read merged min/max flow-limit parameter containers (no per-service meta).
src/services_models/services_constructor.jl Builds interface slack containers once per type (when use_slacks), merges interface time-series parameter population, and folds ORDC cost-expression container creation outside the per-service loop.
src/services_models/service_slacks.jl Refactors interface slack construction to create one dense container per slack type across all interfaces, applying per-interface penalties.
src/core/problem_template.jl Extends the “no available contributing devices” loud error to include interfaces (and keeps ConstantReserveGroup exempt).
src/common_models/add_to_expression.jl Updates interface slack reads and ORDC cost-expression reads to use the merged (empty-meta) containers.
src/common_models/add_expressions.jl Changes reserve-service cost-expression container creation from per-service meta=name to one merged dense (service_name, time) container per service type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Migrate the two remaining meta = interface_name interface containers to merged
per-type containers (keyed by interface name, empty meta), matching the reserve
refactor:
- InterfaceFlowSlackUp/Down: one dense (interface_name, time) container per type,
  built once over all interfaces with per-interface penalty (service_slacks.jl);
  constructors call it once, and the slack fold reads it 3-arg. This also closes
  the use_slacks-on-ServiceModel gap (moving to the vector-axis builder reserves
  already use), so that path is now testable.
- Min/MaxInterfaceFlowLimitParameter: routed to the merged vector _add_parameters!
  (empty meta); the VariableMax InterfaceFlowLimit constraint reads them 3-arg and
  indexes by interface name.
InterfaceTotalFlow (already name-keyed) and InterfaceFlowLimit (meta = ub/lb
direction) are unchanged.

A3: extend the no-contributing-devices loud error to TransmissionInterface (no
available contributing branches), parallel to the reserve arm.

Tests: merged slack shape + penalty wiring (ports the previously-blocked use_slacks
case), merged param shape, and a no-contributing-branch error; removed the stale
NOT-PORTED note. Full suite green except the known converter parallel-flake
(test_converter_network_coverage, passes in isolation). Interface construction
verified by smoke test (mapping + containers + solve).
Mark the reviewer-context comments added in Phase A that narrate the old
per-service meta interface containers (the slack read, the flow-limit-param
read, and the two interface test comments) with DELETE-AFTER-REVIEW, keeping
the durable design/test descriptions. grep the tag to remove them once the PR
is approved.
…stantReserveGroup

Collapse the reserve/interface arms into a single error ("... no available
contributing devices/branches ...") and guard it with
!(service_type <: PSY.ConstantReserveGroup) instead of a positive
Reserve/TransmissionInterface allow-list. A GroupReserve aggregates other
services, so its contributing-device map is empty by design; the exemption
keeps it buildable (the bug that previously blocked ConstantReserveGroup).
Reserves and interfaces do draw on devices/branches, so an empty map there
stays a loud error. AGC is not modeled in POM, so it never reaches here.
Comment above the check explains the exemption. Update the interface error
test substring to match the merged message.
Per Phase A review: mark the transmission_interface_slacks! merged-container
comment with DELETE-AFTER-REVIEW (reviewer context on the container change).
…ice, time) container

Migrate the ORDC (StepwiseCostReserve) production-cost expression off the
per-service meta = name container to one dense (service, time) container per
service type, empty meta - the same shape as the device ProductionCostExpression:
- add_expressions.jl builds one merged container over all the type's services;
- the StepwiseCostReserve constructor calls add_expressions! once (out of the
  per-service loop);
- the ORDC add_to_expression! read/write is now 3-arg (no meta).

The ORDC block-offer variables/constraints are already 3D (service, segment, time)
merged; the slope/breakpoint PWL params stay on meta for now - merging them needs a
shared/padded tranche axis and is coupled with the delta-PWL machinery, so it lands
with the 4D AS-offer work (Phase C). Both ORDC testsets (build + build&solve with
two different-tranche ORDCs) green.
@rodrigomha
rodrigomha force-pushed the rh/dev_refactor_services_pt2 branch from 2423224 to 9b3b8e2 Compare July 30, 2026 16:45
@rodrigomha
rodrigomha marked this pull request as ready for review July 30, 2026 18:36
@rodrigomha
rodrigomha merged commit 9b3b8e2 into rh/dev_refactor_services Jul 30, 2026
3 of 7 checks passed
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