Skip to content
Open
Changes from all commits
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
@@ -1,3 +1,6 @@
from itertools import pairwise


def optimize_route_transfer(grid: Grid, connection_point: NodeArray, new_substation: NodeArray) -> None:
"""Attempt to optimize the route transfer moving the naturally open point (NOP) upstream towards the old substation.
This way, the new substation will take over more nodes of the original route.
Expand All @@ -6,19 +9,19 @@ def optimize_route_transfer(grid: Grid, connection_point: NodeArray, new_substat
path, _ = grid.graphs.active_graph.get_shortest_path(connection_point.id.item(), old_substation_node_id)
print("Path from overload to old substation:", path)

current_branch = grid.line.filter(
open_branch = grid.line.filter(
from_node=[connection_point.id, new_substation.id],
to_node=[connection_point.id, new_substation.id]
)
for from_node, to_node in zip(path[0:-1], path[1:]):
for from_node, to_node in pairwise(path):
# Check if the route is still overloaded
capacity_issues = check_for_capacity_issues(grid)
route_capacity_issues = capacity_issues.filter(feeder_branch_id=connection_point.feeder_branch_id)
if not any(route_capacity_issues):
break

grid.make_active(current_branch)
current_branch = grid.line.filter(from_node=[from_node, to_node], to_node=[from_node, to_node])
grid.make_inactive(current_branch)
grid.make_active(open_branch)
open_branch = grid.line.filter(from_node=[from_node, to_node], to_node=[from_node, to_node])
grid.make_inactive(open_branch)

grid.set_feeder_ids()
Loading