diff --git a/evrouting/gasstation/routing.py b/evrouting/gasstation/routing.py index 580cb3b1520eb7c8185e256e4c345ce02b796c5b..03e87c7467faefd84bc132d53996bc83542f95fc 100644 --- a/evrouting/gasstation/routing.py +++ b/evrouting/gasstation/routing.py @@ -8,8 +8,8 @@ from evrouting.graph_tools import ( DISTANCE_KEY, consumption, distance, - charging_cofficient, ) + from evrouting.graph_tools import sum_weights as fold_path @@ -20,7 +20,8 @@ def insert_start_node(s: Node, graph_extended: nx.DiGraph, capacity: SoC, initial_soc: SoC, - c: float = 1. + c: float = 1., + charging_coefficient=charging_cofficient ) -> nx.DiGraph: """Insert s into extended graph an create states and edges as necessary.""" graph_extended.add_node((s, initial_soc)) @@ -63,6 +64,7 @@ def insert_final_node(t: Node, capacity: SoC, final_soc: SoC, c: float = 1. + charging_cofficient=charging_cofficient ) -> nx.DiGraph: """Insert terminal node into extended graph an create states and edges as necessary.""" graph_extended.add_node((t, final_soc)) diff --git a/evrouting/graph_tools.py b/evrouting/graph_tools.py index 0add35f882a16ece3a78c5e59484c65ee1dec9f1..b724014d14adfc7c951e708b1977ee428130a913 100644 --- a/evrouting/graph_tools.py +++ b/evrouting/graph_tools.py @@ -69,3 +69,20 @@ def consumption_function_distance_factory(consumption: float) -> ConsumptionFunc return G[u][v][CONSUMPTION_KEY] return c + + +class AccessFunctions: + def __init__(self, + distance=distance, + consumption=consumption, + charging_coefficient=charging_cofficient + ): + self.distance = distance + self.consumption = consumption + self.charging_coefficient = charging_coefficient + + def path_distance(self, G, path): + sum_weights(G, path, weight=DISTANCE_KEY) + + def path_consumption(self, G, path): + sum_weights(G, path, weight=CONSUMPTION_KEY)