Skip to content

Add hydro turbine linear commitment formulation#84

Open
acostarelli wants to merge 22 commits intomainfrom
ac/waterlinear-commit
Open

Add hydro turbine linear commitment formulation#84
acostarelli wants to merge 22 commits intomainfrom
ac/waterlinear-commit

Conversation

@acostarelli
Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Collaborator

@luke-kiernan luke-kiernan left a comment

Choose a reason for hiding this comment

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

Based on the fact that you're passing types into get_multiplier_value, I'm inferring that this code wasn't actually run. Will review again once tests work

Comment thread src/common_models/add_parameters.jl Outdated
Co-authored-by: Luke Kiernan <86331877+luke-kiernan@users.noreply.github.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

Adds a new hydro turbine formulation that models linear water-to-power conversion with a binary commitment (on/off) decision, aligning this package with the upstream HydroPowerSimulations.jl port.

Changes:

  • Introduces HydroTurbineWaterLinearCommitment formulation and exports it.
  • Adds device construction logic (variables/constraints/objective wiring) to support the new formulation.
  • Extends hydro cost handling for time-variant proportional terms and adds a regression test covering reservoir budget + turbine commitment.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/core/formulations.jl Defines the new HydroTurbineWaterLinearCommitment formulation type.
src/PowerOperationsModels.jl Exports the new formulation so it’s usable by templates.
src/static_injector_models/hydrogeneration_constructor.jl Adds construct_device! implementations for the new commitment formulation.
src/static_injector_models/hydro_generation.jl Extends variable/constraint support for the new formulation and adds “variant” proportional-cost plumbing.
test/test_device_hydro_constructors.jl Adds a solve test for HydroWaterModelReservoir with budget + the new commitment turbine model.
Project.toml Adds an InfrastructureSystems [sources] override and modifies compat entries.

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

Comment on lines +25 to +26
lin_cost = _add_proportional_term_helper(
container, T(), component, linear_term, time_period)
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

_add_proportional_term_variant! calls _add_proportional_term_helper, but that helper isn’t defined anywhere in the repo. This will throw a UndefVarError at runtime whenever a time-variant proportional cost term is encountered (e.g., MarketBidCost on-costs). Consider inlining the same variable lookup logic used in _add_proportional_term! (but adding to the variant objective expression) or defining the missing helper.

Suggested change
lin_cost = _add_proportional_term_helper(
container, T(), component, linear_term, time_period)
component_name = PSY.get_name(component)
variable = get_variable(container, T, U)[component_name, time_period]
lin_cost = variable * linear_term

Copilot uses AI. Check for mistakes.
@acostarelli acostarelli marked this pull request as draft April 23, 2026 06:56
end
add_to_expression!(container, ProductionCostExpression, exp, d, t)
end
cost_term = proportional_cost(op_cost_data, U, d, V)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@luke-kiernan Is this proper use of the new IOM code? Or would it be better to just have the one add_proportional_cost function? I don't know how much performance is lost to the "maybe variant" part.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Your definition here is non-time-varying, so I suspect it's redundant: the default add_proportional_cost! in IOM should handle it just fine.

Copy link
Copy Markdown
Collaborator

@luke-kiernan luke-kiernan left a comment

Choose a reason for hiding this comment

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

There's bigger structural issues here: this file is still basically a copy-paste from PSI. In the initial PSI-into-POM/IOM split, I deferred refactoring the hydro code to "later," perhaps due to the separate HPS package. I never returned to that task. I've opened #96 for this and will tackle it ASAP (today and tomorrow).

Until that's finished, imo it doesn't make sense to merge this. Core issues first then add new features.

Aside: clearly we need better test coverage. This file calls functions that don't exist.

@acostarelli acostarelli marked this pull request as ready for review April 27, 2026 16:26
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

Performance Results

Version Precompile Time
Main 2.909687642
This Branch 2.929410645
Version Build Time
Main-Build Time Precompile 103.423229125
Main-Build Time Postcompile 14.953282185
This Branch-Build Time Precompile 100.923549155
This Branch-Build Time Postcompile 14.74935103
Version Solve Time
Main-Solve Time Precompile 399.44200545
Main-Solve Time Postcompile 366.013958829
This Branch-Solve Time Precompile 168.360271924
This Branch-Solve Time Postcompile 135.097179579

return
end

_maybe_add_on_variables!(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@luke-kiernan What do you think of this pattern?

Comment thread src/core/formulations.jl
"""
struct HydroPumpEnergyCommitment <: AbstractHydroPumpFormulation end

"""
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@luke-kiernan and this? For simplifying unions

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