From e35c8ca6357cc07dba7a715344fd5b6d08e92f73 Mon Sep 17 00:00:00 2001 From: "niehues.mark@gmail.com" <niehues.mark@gmail.com> Date: Wed, 18 Mar 2020 12:29:15 +0100 Subject: [PATCH] further test case --- evrouting/charge/routing.py | 8 ++++++++ tests/charge/test_charge_routing.py | 10 +++++++++- tests/config.py | 24 +++++++++++++++++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/evrouting/charge/routing.py b/evrouting/charge/routing.py index 033b37e..2653c90 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 cd627ba..6d6a5a2 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 ba91c6f..51f4617 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, -- GitLab