From 33bf4b6332ee45efe57e7f295c91ffb08b11be32 Mon Sep 17 00:00:00 2001 From: Tony Xiang <19280867+TonyXiang8787@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:11:50 +0100 Subject: [PATCH] Update power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/observability.hpp Co-authored-by: Martijn Govers Signed-off-by: Tony Xiang <19280867+TonyXiang8787@users.noreply.github.com> --- .../include/power_grid_model/math_solver/observability.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/observability.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/observability.hpp index 0f3f46e75..955af1b40 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/observability.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/observability.hpp @@ -88,12 +88,10 @@ inline void assign_injection_sensor_radial(YBusStructure const& y_bus_structure, if (flow_sensors[branch_entry_upstream] == 0) { if (flow_sensors[bus_entry_current] == 1) { // try to steal from current bus - flow_sensors[bus_entry_current] = 0; - flow_sensors[branch_entry_upstream] = 1; + std::swap(flow_sensors[branch_entry_upstream], flow_sensors[bus_entry_current]); } else if (flow_sensors[bus_entry_upstream] == 1) { // if not possible, steal from upstream bus - flow_sensors[bus_entry_upstream] = 0; - flow_sensors[branch_entry_upstream] = 1; + std::swap(flow_sensors[branch_entry_upstream], flow_sensors[bus_entry_upstream]); } } // remove the current bus injection regardless of the original state