diff --git a/evrouting/charge/routing.py b/evrouting/charge/routing.py index 033b37e412ad647486b0ab902b262b7e62aa8f55..2653c90125db877399ee9b8c7584066a5b0f6444 100644 --- a/evrouting/charge/routing.py +++ b/evrouting/charge/routing.py @@ -142,6 +142,14 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node, ) ) except ValueError: + # Infeasible because last_cs might be an + # dummy charging station. Therefore, the path might + # be infeasible even though one could reach it with a full + # battery, because charging is not possible at dummy + # stations. + # + # That means, the SoC and thereby the range is restricted + # to the SoC at the last cs (soc_last_cs). pass else: if l_new == l_uns[n].peak_min(): diff --git a/tests/charge/test_charge_routing.py b/tests/charge/test_charge_routing.py index cd627baece2e1cf5509a5e64a8e269867c9eff77..6d6a5a28166937fb2e985f86df6c635ebbbdd8de 100644 --- a/tests/charge/test_charge_routing.py +++ b/tests/charge/test_charge_routing.py @@ -3,17 +3,25 @@ from evrouting.charge import shortest_path from ..config import ( edge_case, edge_case_start_node_no_cs, + edge_case_a_slow, init_config ) -def test_shortest_path_charge_at_s(): +def test_shortest_path_charge_at_s_and_a(): """Charging at s.""" path = shortest_path(**init_config(edge_case)) assert path == 3.5 +def test_shortest_path_charge_at_s_only(): + """Charging at s.""" + path = shortest_path(**init_config(edge_case_a_slow)) + + assert path == 3 + + def test_shortest_path_no_charge_s_path_t(): """No charging at s but enough initial SoC to go to t directly.""" conf = init_config(edge_case_start_node_no_cs) diff --git a/tests/config.py b/tests/config.py index ba91c6f9594a7a73d7519e5742d725a3c4397ce0..51f4617ee1827b3304797d796a64ac5552fad5ac 100644 --- a/tests/config.py +++ b/tests/config.py @@ -8,7 +8,11 @@ from evrouting.graph_tools import ( ) # List of configs -config_list = ['edge_case', 'edge_case_start_node_no_cs'] +config_list = [ + 'edge_case', + 'edge_case_start_node_no_cs', + 'edge_case_a_slow' +] edge_case = { 'beta_s': 0, @@ -28,6 +32,24 @@ edge_case = { ] } +edge_case_a_slow = { + 'beta_s': 0, + 'beta_t': 0, + 'U': 4, + 's': 0, + 't': 2, + 'nodes': [ + TemplateNode('s', charging_coeff=2), + TemplateNode('a', charging_coeff=1), + TemplateNode('t'), + ], + 'edges': [ + TemplateEdge(0, 1, distance=1, consumption=1), + TemplateEdge(0, 2, distance=1, consumption=4), + TemplateEdge(1, 2, distance=1, consumption=1), + ] +} + edge_case_start_node_no_cs = { 'beta_s': 0, 'beta_t': 0,