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

further test case

parent 9392932e
No related branches found
No related tags found
No related merge requests found
...@@ -142,6 +142,14 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node, ...@@ -142,6 +142,14 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
) )
) )
except ValueError: 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 pass
else: else:
if l_new == l_uns[n].peak_min(): if l_new == l_uns[n].peak_min():
......
...@@ -3,17 +3,25 @@ from evrouting.charge import shortest_path ...@@ -3,17 +3,25 @@ from evrouting.charge import shortest_path
from ..config import ( from ..config import (
edge_case, edge_case,
edge_case_start_node_no_cs, edge_case_start_node_no_cs,
edge_case_a_slow,
init_config init_config
) )
def test_shortest_path_charge_at_s(): def test_shortest_path_charge_at_s_and_a():
"""Charging at s.""" """Charging at s."""
path = shortest_path(**init_config(edge_case)) path = shortest_path(**init_config(edge_case))
assert path == 3.5 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(): def test_shortest_path_no_charge_s_path_t():
"""No charging at s but enough initial SoC to go to t directly.""" """No charging at s but enough initial SoC to go to t directly."""
conf = init_config(edge_case_start_node_no_cs) conf = init_config(edge_case_start_node_no_cs)
......
...@@ -8,7 +8,11 @@ from evrouting.graph_tools import ( ...@@ -8,7 +8,11 @@ from evrouting.graph_tools import (
) )
# List of configs # 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 = { edge_case = {
'beta_s': 0, 'beta_s': 0,
...@@ -28,6 +32,24 @@ edge_case = { ...@@ -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 = { edge_case_start_node_no_cs = {
'beta_s': 0, 'beta_s': 0,
'beta_t': 0, 'beta_t': 0,
......
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