Skip to content

Conversation

@Jerry-Jinfeng-Guo
Copy link
Member

@Jerry-Jinfeng-Guo Jerry-Jinfeng-Guo commented Oct 24, 2025

The binary search logic in any mode can not handle edge case when u_band is significantly smaller than tap_size due to the lack of back-forth jumping behavior. This PR fixes that and fast_any_tap strategy now correctly throws a MaxIterationReached error in equivalent cases as other strategies do.

  • The fix
  • Tests

Note: the edge case is in itself not a valid input, as unrealistic u_band shouldn't be allowed, this PR aligns the behavior across different strategies.

This PR relates to #887

@Jerry-Jinfeng-Guo Jerry-Jinfeng-Guo self-assigned this Oct 24, 2025
@Jerry-Jinfeng-Guo Jerry-Jinfeng-Guo added the bug Something isn't working label Oct 24, 2025
Copy link
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 fixes a bug in the fast_any_tap strategy where the binary search logic fails to handle edge cases when u_band is significantly smaller than tap_size. The fix ensures that fast_any_tap now correctly throws a MaxIterationReached error in cases equivalent to other strategies, aligning behavior across different tap-changing strategies.

Key changes:

  • Modified binary search logic to detect when no valid tap position exists within the search range
  • Added validation to throw MaxIterationReached when the search cannot converge
  • Added test cases for both fast_any_tap and any_valid_tap strategies with extremely small u_band values

Reviewed Changes

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

File Description
power_grid_model_c/power_grid_model/include/power_grid_model/optimizer/tap_position_optimizer.hpp Adds rewind method and validation logic to detect invalid tap positions in binary search
tests/data/power_flow/automatic-tap-regulator/auto-tap-changer-repro-fast-any/* Test case for fast_any_tap strategy with unrealistically small u_band (0.00001) expecting MaxIterationReached
tests/data/power_flow/automatic-tap-regulator/auto-tap-changer-repro-any/* Test case for any_valid_tap strategy with same configuration for comparison

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

…-meshed-any-max-iter/params.json

Signed-off-by: Jerry Guo <[email protected]>
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants