Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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 forInfrastructureSystemsfromProject.tomlandtest/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) |
| @@ -53,7 +49,8 @@ function add_constraints!( | |||
| constraint = get_constraint(container, RequirementConstraint(), SR, service_name) | |||
acostarelli
reviewed
Apr 16, 2026
acostarelli
reviewed
Apr 16, 2026
Collaborator
Author
|
This is basically finished, just pending 2 things:
|
…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
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All except for ~10 tests are passing, with IOM on
main(last commit: PR 71 merge), PSY onjd/mbc_iec_refactor(last commit:18198590c0), IS onjd/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
IS4and PSY'spsy6) tomorrow. Note to self: there's also a handful of runtime calls to fix,typeof(x).