Skip to content

Fix thermal min-up/down rounding and improve parallel-branch interface error messages#181

Merged
jd-lara merged 1 commit into
mainfrom
ac/pom-bugfixes
Jul 19, 2026
Merged

Fix thermal min-up/down rounding and improve parallel-branch interface error messages#181
jd-lara merged 1 commit into
mainfrom
ac/pom-bugfixes

Conversation

@acostarelli

Copy link
Copy Markdown
Member

Two small fixes ported from PSI:

  • Thermal min-up/down rounding — drop the stray Float64 positional argument in round(..., RoundUp) in _get_data_for_tdc (thermal_generation.jl), which is incompatible with the RoundingMode argument.
  • Parallel-branch interface error message — when a transmission interface names only part of a reduced double-circuit / degree-two chain, list the offending branch names in the ArgumentError (re-ported onto main's _error_msg(T) helper).

Ported from PSI

The HVDC area-balance fix (#1519) originally bundled with this work is already present on main, so it is not included here.


Part of splitting the former #154 into focused PRs.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

Performance Results

Version Precompile Time
Main 3.004515364
This Branch 2.956910858
Version Build Time
Main-Build Time Precompile 87.061163456
Main-Build Time Postcompile 1.06286185
This Branch-Build Time Precompile 84.969763367
This Branch-Build Time Postcompile 1.276642497
Version Solve Time
Main-Solve Time Precompile 409.064972609
Main-Solve Time Postcompile 378.326068773
This Branch-Solve Time Precompile 2064.628520318
This Branch-Solve Time Postcompile 2038.460372829

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

This PR ports two small fixes from PowerSimulations.jl into PowerOperationsModels.jl: (1) correct rounding for thermal min up/down time conversion in the duration-constraint data path, and (2) improve the diagnostic error message when a transmission interface only partially specifies a reduced parallel/series branch grouping.

Changes:

  • Fix _get_data_for_tdc to call round(x, RoundUp) without an incompatible positional Float64 argument.
  • Enhance _reduced_entry_in_interface to include the reduced-entry branch names in the thrown ArgumentError.

Reviewed changes

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

File Description
src/static_injector_models/thermal_generation.jl Fixes rounding call used when converting time limits into per-resolution step counts for duration constraints.
src/common_models/add_to_expression.jl Improves interface reduction validation errors by listing the branch names involved in the offending reduced entry.

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

@acostarelli
acostarelli requested a review from luke-kiernan July 14, 2026 13:34

@luke-kiernan luke-kiernan left a comment

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.

Thermal min-up/down rounding — drop the stray Float64 positional argument in round(..., RoundUp) in _get_data_for_tdc (thermal_generation.jl), which is incompatible with the RoundingMode argument.

I'm confused: round(Float64, 1.4, RoundUp) runs just fine for me in REPL. AI hallucination?

ini_conds[idx, 2] = initial_conditions_off[ix]
up_val = round(Float64, time_limits.up * steps_per_hour, RoundUp)
down_val = round(Float64, time_limits.down * steps_per_hour, RoundUp)
up_val = round(time_limits.up * steps_per_hour, RoundUp)

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.

round picks same type as the argument. If time_limits.up and steps_per_hour both are ints, then up_val will also be an int. Check that one or the other is a float so that up_val is consistently a float, not an int

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.

From PSY docs:

get_time_limits(
      value::ThermalStandard
  ) -> Union{Nothing, @NamedTuple{up::Float64, down::Float64}}

So the argument is definitely a float. The change came from Sienna-Platform/PowerSimulations.jl#1527 , so it could've been an AI hallucination there but doesn't feel like it to me.

I'm also unsure why this change was made. It definitely wasn't a method error before, and I would be surprised if there was any other issue.

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.

You need to revert this. Just leave the improving on erroring message.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The optimization models take only Floats, it makes no sense to do it with integer

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.

I left a comment below but replying again here. Since the argument we're passing is always a float, the return type will also be a float. Unless we're anticipating that up or down will change types then this should be safe.

ini_conds[idx, 2] = initial_conditions_off[ix]
up_val = round(Float64, time_limits.up * steps_per_hour, RoundUp)
down_val = round(Float64, time_limits.down * steps_per_hour, RoundUp)
up_val = round(time_limits.up * steps_per_hour, RoundUp)

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.

You need to revert this. Just leave the improving on erroring message.

@acostarelli

Copy link
Copy Markdown
Member Author

@rodrigomha Sure. Why was this change made in the first place? Are we anticipating that .up will change types?

The reduced-entry interface check reported that an interface covers only
part of a reduced parallel or series group without identifying which
branches were involved, leaving no way to locate the offending data.
@jd-lara
jd-lara merged commit 3556597 into main Jul 19, 2026
6 checks passed
@jd-lara
jd-lara deleted the ac/pom-bugfixes branch July 19, 2026 15:20
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.

6 participants