Skip to content

Allow meshed control transformers #927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ using EdgeWeight = int64_t;
using RankedTransformerGroups = std::vector<std::vector<Idx2D>>;

constexpr auto infty = std::numeric_limits<Idx>::max();
constexpr auto last_rank = infty - 1;
constexpr Idx2D unregulated_idx = {-1, -1};
struct TrafoGraphVertex {
bool is_source{};
Expand Down Expand Up @@ -309,7 +310,7 @@ inline auto get_edge_weights(TransformerGraph const& graph) -> TrafoGraphEdgePro
}
auto const edge_src_rank = vertex_distances[boost::source(e, graph)];
auto const edge_tgt_rank = vertex_distances[boost::target(e, graph)];
auto const edge_res = std::min(edge_src_rank, edge_tgt_rank);
auto edge_res = std::min(edge_src_rank, edge_tgt_rank);

// New edge logic for ranking
// | Tap | Control | All edges |
Expand All @@ -328,13 +329,18 @@ inline auto get_edge_weights(TransformerGraph const& graph) -> TrafoGraphEdgePro
// side via the bidirectional edge (if it exists). For delta configuration ABC, the above
// situations can happen.
// The logic still holds in meshed grids, albeit operating a more complex graph.
if (edge_src_rank != edge_tgt_rank - 1) {
throw AutomaticTapInputError("The control side of a transformer regulator should be relatively further "
"away from the source than the tap side.\n");
if (is_unreachable(edge_res)) {
continue;
}
if (!is_unreachable(edge_res)) {
result.emplace_back(graph[e].regulated_idx, edge_tgt_rank);
if (edge_src_rank == infty && edge_tgt_rank != infty) {
throw AutomaticTapInputError(
"The transformer is being controlled from non source side towards source side which is unsupported.\n");
}
if (edge_src_rank != edge_tgt_rank - 1) {
edge_res = last_rank;
}

result.emplace_back(graph[e].regulated_idx, edge_tgt_rank);
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion tests/cpp_unit_tests/test_tap_position_optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ TEST_CASE("Test Transformer ranking") {

SUBCASE("Ranking complete the graph") {
// The test grid 1 is not compatible with the updated logic for step up transformers
CHECK_THROWS_AS(pgm_tap::rank_transformers(state), AutomaticTapInputError);
// CHECK_THROWS_AS(pgm_tap::rank_transformers(state), AutomaticTapInputError);
}
}

Expand Down
Loading