Skip to content

Update POM to IOM type-dispatch API#82

Merged
jd-lara merged 7 commits intomainfrom
lk/update-pom-to-iom-type-dispatch
Apr 16, 2026
Merged

Update POM to IOM type-dispatch API#82
jd-lara merged 7 commits intomainfrom
lk/update-pom-to-iom-type-dispatch

Conversation

@luke-kiernan
Copy link
Copy Markdown
Collaborator

@luke-kiernan luke-kiernan commented Apr 16, 2026

IOM PR 71 changed interface functions from instance dispatch (::T) to type dispatch (::Type{T}) for VariableType, ConstraintType, ExpressionType, ParameterType, and formulation subtypes. This commit updates POM accordingly:

  • Convert ~800+ call sites from SomeKey() to SomeKey for get_variable, get_expression, get_parameter, add_*_container!, lazy_container_addition!
  • Convert all get_variable_binary/upper_bound/lower_bound/warm_start_value definitions to use ::Type{X} for variable and formulation args
  • Convert objective function interfaces (proportional_cost, objective_function_multiplier, variable_cost, start_up_cost, etc.)
  • Fix POM-local add_variables! overrides to extract formulation type via ::F where F pattern
  • Add device type annotations to get_min_max_limits to resolve ambiguities with IOM default
  • Update test helpers and test call sites

All except for ~10 tests are passing, with IOM on main (last commit: PR 71 merge), PSY on jd/mbc_iec_refactor (last commit: 18198590c0), IS on jd/namedtuple_time_series (last commit: 9731128b0f9).

I'll look at those last dozen tests, fix the merge conflicts, and reconcile with further upstream changes (e.g. compatibility with IS's IS4 and PSY's psy6) tomorrow. Note to self: there's also a handful of runtime calls to fix, typeof(x).

IOM PR #71 changed interface functions from instance dispatch (::T) to
type dispatch (::Type{T}) for VariableType, ConstraintType, ExpressionType,
ParameterType, and formulation subtypes. This commit updates POM accordingly:

- Convert ~800+ call sites from SomeKey() to SomeKey for get_variable,
  get_expression, get_parameter, add_*_container!, lazy_container_addition!
- Convert all get_variable_binary/upper_bound/lower_bound/warm_start_value
  definitions to use ::Type{X} for variable and formulation args
- Convert objective function interfaces (proportional_cost,
  objective_function_multiplier, variable_cost, start_up_cost, etc.)
- Fix POM-local add_variables! overrides to extract formulation type via
  ::F where F pattern
- Add device type annotations to get_min_max_limits to resolve ambiguities
  with IOM default
- Update test helpers and test call sites

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates PowerOperationsModels (POM) to match InfrastructureOptimizationModels (IOM) PR 71’s API change from instance-dispatch (SomeKey()) to type-dispatch (SomeKey) across variable/constraint/expression/parameter and formulation interfaces.

Changes:

  • Convert many container access/addition call sites to pass key types (e.g., get_variable(..., T, U)), and update helper/test utilities accordingly.
  • Update numerous interface methods (bounds, multipliers, cost hooks, etc.) to dispatch on ::Type{...} for variable/constraint/expression/parameter keys and formulations.
  • Remove [sources] overrides for InfrastructureSystems from Project.toml and test/Project.toml.

Reviewed changes

Copilot reviewed 38 out of 39 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/test_utils/model_checks.jl Updates test helper calls to type-dispatch get_variable/get_expression/get_constraint.
test/test_network_constructors_with_dlr.jl Updates PTDF branch flow expression lookup to type-dispatch.
test/test_model_decision.jl Updates variable lookup in decision-model tests to pass key types.
test/test_initialization_problem.jl Updates initialization tests to pass key types for variable/constraint counting helpers.
test/Project.toml Removes InfrastructureSystems [sources] override.
src/twoterminal_hvdc_models/TwoTerminalDC_branches.jl Migrates HVDC PWL loss + flow constraints code to type-dispatch APIs (one remaining instance-formulation bug noted).
src/twoterminal_hvdc_models/AC_branches.jl Migrates HVDC AC-branch model code to type-dispatch (one remaining formulation-type bug noted).
src/static_injector_models/thermal_generation.jl Updates thermal injector interfaces (bounds, multipliers, objective hooks) to ::Type{...} dispatch and tightens get_min_max_limits device types.
src/static_injector_models/source.jl Updates source model interfaces and objective hooks to type-dispatch.
src/static_injector_models/renewable_generation.jl Updates renewable model interfaces/objective hooks to type-dispatch.
src/static_injector_models/reactivepower_device.jl Updates synchronous condenser interfaces to type-dispatch.
src/static_injector_models/electric_loads.jl Updates load model interfaces/objective hooks and proportional cost wiring to type-dispatch.
src/services_models/transmission_interface.jl Updates transmission interface service lookups and parameter handling to type-dispatch.
src/services_models/services_constructor.jl Updates lazy expression container initialization for interface flows to type-dispatch.
src/services_models/service_slacks.jl Updates reserve slack variable container addition to type-dispatch.
src/services_models/reserves.jl Updates reserves variables/constraints/objective integration to type-dispatch.
src/services_models/reserve_group.jl Updates reserve-group variable/constraint creation to type-dispatch (one remaining get_constraint call still instance-based noted).
src/services_models/agc.jl Updates AGC service variable/constraint wiring to type-dispatch (one emergency-down variable selection bug noted).
src/network_models/security_constrained_models.jl Updates SC network constraints to use type-dispatch containers.
src/network_models/powermodels_interface.jl Updates PM variable/constraint reference container creation to pass key types.
src/network_models/network_slack_variables.jl Updates slack variables and objective contributions to type-dispatch.
src/network_models/hvdc_networks.jl Updates HVDC network constraint construction to type-dispatch.
src/network_models/copperplate_model.jl Updates copperplate balance constraints to type-dispatch.
src/network_models/area_balance_model.jl Updates area balance constraints and emergency expressions to type-dispatch.
src/mt_hvdc_models/hvdcsystems_constructor.jl Updates MT-HVDC constructor call sites to pass variable key types.
src/mt_hvdc_models/HVDCsystems.jl Updates MT-HVDC variable bounds/multipliers and expression wiring to type-dispatch.
src/energy_storage_models/storage_models.jl Updates storage interfaces, reserve coupling, and objective hooks to type-dispatch.
src/energy_storage_models/storage_constructor.jl Updates ancillary-services lazy expression container creation to type-dispatch.
src/core/interfaces.jl Updates core interface signatures to accept ::Type{...} keys/formulations.
src/core/default_interface_methods.jl Updates default multiplier-value methods to type-dispatch.
src/common_models/reserve_range_constraints.jl Updates reserve-range constraints to use type-dispatch get_variable/get_expression.
src/common_models/market_bid_overrides.jl Updates market bid overrides and PWL helper wiring to type-dispatch.
src/common_models/add_parameters.jl Updates parameter creation and multiplier/value retrieval to type-dispatch.
src/common_models/add_expressions.jl Updates expression container creation to type-dispatch.
src/area_interchange.jl Updates area interchange parameters/variables/constraints to type-dispatch.
src/ac_transmission_models/AC_branches.jl Updates AC branch interfaces and constraint construction to type-dispatch.
Project.toml Removes InfrastructureSystems [sources] override.

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

Comment on lines +192 to +196
formulation = HVDCTwoTerminalPiecewiseLoss()
T = HVDCPiecewiseLossVariable
binary_T = get_variable_binary(T(), D, formulation)
binary_T = get_variable_binary(T, D, formulation)
U = HVDCPiecewiseBinaryLossVariable
binary_U = get_variable_binary(U(), D, formulation)
binary_U = get_variable_binary(U, D, formulation)
Comment on lines +100 to +101
ub = get_variable_upper_bound(T, reduction_entry, formulation)
lb = get_variable_lower_bound(T, reduction_entry, formulation)
get_variable(container, AdditionalDeltaActivePowerUpVariable, PSY.Area)
R_dn_emergency =
get_variable(container, AdditionalDeltaActivePowerUpVariable(), PSY.Area)
get_variable(container, AdditionalDeltaActivePowerUpVariable, PSY.Area)
Comment thread src/services_models/reserve_group.jl Outdated
@@ -53,7 +49,8 @@ function add_constraints!(
constraint = get_constraint(container, RequirementConstraint(), SR, service_name)
@luke-kiernan luke-kiernan marked this pull request as ready for review April 16, 2026 17:34
@luke-kiernan luke-kiernan requested a review from jd-lara April 16, 2026 17:34
Comment thread src/services_models/reserves.jl Outdated
Comment thread src/static_injector_models/thermal_generation.jl Outdated
@luke-kiernan
Copy link
Copy Markdown
Collaborator Author

luke-kiernan commented Apr 16, 2026

This is basically finished, just pending 2 things:

  • Fix the merge conflicts
  • Merge IOM PR #80. Until that's merged, tests will probably fail. Even with that merged, I'm still seeing 3 failures, but they're due to PSB stuff.

…type-dispatch

# Conflicts:
#	src/static_injector_models/electric_loads.jl
#	src/static_injector_models/hydro_generation.jl
#	src/static_injector_models/thermal_generation.jl
@jd-lara jd-lara merged commit 62708c0 into main Apr 16, 2026
1 of 6 checks passed
@jd-lara jd-lara deleted the lk/update-pom-to-iom-type-dispatch branch April 16, 2026 21:13
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.

4 participants