Skip to content

Cost expression refactor, parameter broadcasting, and PF headroom slack porting#112

Open
acostarelli wants to merge 8 commits intomainfrom
ac/psi-costexp-parambroad-pfslack
Open

Cost expression refactor, parameter broadcasting, and PF headroom slack porting#112
acostarelli wants to merge 8 commits intomainfrom
ac/psi-costexp-parambroad-pfslack

Conversation

@acostarelli
Copy link
Copy Markdown
Member

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 ports PowerSimulations.jl cost-expression refactors, parameter broadcasting fixes, and power-flow-in-the-loop (PFitL) functionality into PowerOperationsModels.jl, including headroom-proportional slack participation and expanded cost-expression reporting.

Changes:

  • Refactors device constructors to register cost expressions via a new add_cost_expressions! bundle and expands exported cost-expression types.
  • Reworks time-series parameter population/multiplier handling (including a regression fix for parallel-branch multipliers) using IOM fast-path setters.
  • Implements PFitL in PowerFlowsExt (input mapping, data update, solve/aux readback, headroom slack) and adds new regression/coverage tests.

Reviewed changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/test_power_flow_in_the_loop.jl Adds PFitL tests including headroom-proportional slack coverage and baseline PFitL scenarios.
test/test_parallel_branch_parameter_multipliers.jl Adds regression test ensuring per-branch multiplier rows are populated (no NaNs) for parallel branches.
test/test_model_decision.jl Updates expected expression counts and realized output export assertions for the expanded cost-expression set.
test/test_device_thermal_generation_constructors.jl Expands thermal cost tests to validate constituent decomposition and startup-cost behavior.
test/test_device_renewable_generation_constructors.jl Adds nonnegativity test for CurtailmentCostExpression.
test/Project.toml Pins test dependency rev of InfrastructureOptimizationModels to the required branch.
src/static_injector_models/thermalgeneration_constructor.jl Switches from individual add_expressions! calls to add_cost_expressions! for thermals.
src/static_injector_models/source_constructor.jl Switches sources to add_cost_expressions!.
src/static_injector_models/renewablegeneration_constructor.jl Switches renewables to add_cost_expressions!.
src/static_injector_models/renewable_generation.jl Adds curtailment-cost hook in renewable objective building.
src/static_injector_models/load_constructor.jl Switches loads to add_cost_expressions!.
src/static_injector_models/hydro_generation.jl Uses IOM internal setters for faster parameter/multiplier writes in hydro parameter population.
src/PowerOperationsModels.jl Adds explicit imports/exports for cost-expression bindings and includes new objective helper file.
src/core/interfaces.jl Improves add_power_flow_data! fallback behavior and error message when PowerFlows extension isn’t loaded.
src/common_models/objective_function.jl Introduces renewable curtailment-cost expression generation.
src/common_models/market_bid_plumbing.jl Routes VOM costs into VOMCostExpression via updated IOM helper signature.
src/common_models/add_to_expression.jl Refactors fuel-consumption expression construction (dispatch-based methods) and compact-formulation handling.
src/common_models/add_parameters.jl Reworks time-series parameter/multiplier population via IOM fast setters and fixes parallel-branch multiplier axis bug.
src/common_models/add_expressions.jl Adds add_cost_expressions! bundles and fuel-curve predicates for container setup decisions.
Project.toml Pins main dependency rev of InfrastructureOptimizationModels to the required branch.
ext/PowerFlowsExt/PowerFlowsExt.jl Sets up the PowerFlows extension module and includes PFitL implementation files.
ext/PowerFlowsExt/pf_input_mapping.jl Implements PF input key mapping and aux-var container creation for PFitL.
ext/PowerFlowsExt/pf_data_update.jl Implements writing optimization results into PF data/system for PFitL.
ext/PowerFlowsExt/pf_headroom.jl Implements headroom-proportional slack participation factor recomputation.
ext/PowerFlowsExt/pf_solve_and_aux.jl Implements PF solve dispatch and aux-variable readback from PF results.

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

for t in get_time_steps(container)
offer_max = _renewable_offer_max(container, component, name, t)
dispatch = dispatch_vars[name, t]
curtailment_cost = proportional_term_per_unit * dt * (offer_max - dispatch)
"Fetch the most recently solved `PowerFlowEvaluationData`"
function latest_solved_power_flow_evaluation_data(container::OptimizationContainer)
datas = get_power_flow_evaluation_data(container)
return datas[findlast(x -> x.is_solved, datas)]
# Skip the aux vars that the current power flow isn't meant to update
pf_e_data = latest_solved_power_flow_evaluation_data(container)
pf_data = get_power_flow_data(pf_e_data)
(key in branch_aux_vars(pf_data) || key in bus_aux_vars(pf_data)) && return
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Performance Results

Version Precompile Time
Main 3.159168683
This Branch 3.101612523
Version Build Time
Main-Build Time Precompile 114.499653702
Main-Build Time Postcompile 17.613415757
This Branch-Build Time Precompile 118.818209652
This Branch-Build Time Postcompile 18.016241143
Version Solve Time
Main-Solve Time Precompile 420.732363471
Main-Solve Time Postcompile 382.82384593
This Branch-Solve Time Precompile 190.69656838
This Branch-Solve Time Postcompile 147.489961602

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