Skip to content
Snippets Groups Projects
Commit 9392932e authored by markn92's avatar markn92
Browse files

add key to label datastructure

parent 3c7f74c7
No related branches found
No related tags found
No related merge requests found
......@@ -103,7 +103,7 @@ class ChargingFunction:
if self.initial_soc is None:
raise ValueError(
'Charging coefficient is 0 but no initial SoC given.'
)
)
soc = self.initial_soc
else:
soc = initial_soc + self.c * t
......@@ -160,6 +160,11 @@ class Label(NamedTuple):
last_cs: Node
soc_profile_cs_v: SoCProfile
@property
def key(self):
"""Key for sorting."""
return self.t_trip
class SoCFunction:
"""
......@@ -206,7 +211,7 @@ class SoCFunction:
return self.soc_profile_cs_v(
self.cf_cs(t - self.t_trip, self.soc_last_cs)
)
)
@property
def minimum(self) -> Time:
......
......@@ -116,7 +116,7 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
# l_uns[v] empty
q.delete_min()
else:
q.insert(minimum_node, key(label_minimum_node))
q.insert(minimum_node, label_minimum_node.key)
# scan outgoing arcs
for n in G.neighbors(minimum_node):
......@@ -145,8 +145,4 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
pass
else:
if l_new == l_uns[n].peak_min():
q.insert(n, key(l_new))
def key(l: Label) -> Time:
return l.t_trip
q.insert(n, l_new.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