Skip to content
Snippets Groups Projects
Commit 6ca9aa6c authored by markn92's avatar markn92
Browse files

minor

parent 1b819739
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ Implementation of the CHArge algorithm [0] with two further constraints: ...@@ -7,7 +7,7 @@ Implementation of the CHArge algorithm [0] with two further constraints:
[0] https://dl.acm.org/doi/10.1145/2820783.2820826 [0] https://dl.acm.org/doi/10.1145/2820783.2820826
""" """
from typing import Dict, List, Tuple, Set, Union from typing import Dict, List, Tuple, Set
from math import inf from math import inf
import networkx as nx import networkx as nx
......
from typing import Set, List, Tuple from typing import Set, List
import networkx as nx import networkx as nx
from evrouting.T import Node, SoC, Result, EmptyResult, Time from evrouting.T import Node, SoC, Result, EmptyResult, Time
...@@ -106,12 +106,12 @@ def contract_graph(G: nx.Graph, charging_stations: Set[Node], capacity: SoC, ...@@ -106,12 +106,12 @@ def contract_graph(G: nx.Graph, charging_stations: Set[Node], capacity: SoC,
# Iterate unvisited charging stations # Iterate unvisited charging stations
for n_cs in [n for n in charging_stations if (n, cs) not in H.edges and n != cs]: for n_cs in [n for n in charging_stations if (n, cs) not in H.edges and n != cs]:
min_path: List[Node] = dist(G, cs, n_cs) min_path: List[Node] = dist(G, cs, n_cs)
consumption: SoC = fold_path(G, min_path, weight=CONSUMPTION_KEY) w_cs_n: SoC = fold_path(G, min_path, weight=CONSUMPTION_KEY)
if consumption <= capacity: if w_cs_n <= capacity:
H.add_edge( H.add_edge(
cs, n_cs, cs, n_cs,
**{ **{
CONSUMPTION_KEY: consumption, CONSUMPTION_KEY: w_cs_n,
DISTANCE_KEY: fold_path(G, min_path, weight=DISTANCE_KEY) DISTANCE_KEY: fold_path(G, min_path, weight=DISTANCE_KEY)
} }
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment