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

makes sense so far

parent bf73f7e6
No related branches found
No related tags found
No related merge requests found
......@@ -105,23 +105,35 @@ def test_charge_shortest_route_stop(map_graph):
cost_path = 6 * consumption * 1000 # distance * consumption in Wh
c = consumption_function_distance_factory(consumption)
mu_s = 2000
mu_t = 0
result = charge.routing.shortest_path(
G=map_graph,
charging_stations=map_graph.charging_stations,
s=_s,
t=_t,
initial_soc=2000, # > cost_path
final_soc=0,
initial_soc=mu_s, # > cost_path
final_soc=mu_t,
capacity=10000,
c=c
)
assert type(result) is Result
charge_at = [t for n, t in result.charge_path if t > 0]
charge_at = [(n, t) for n, t in result.charge_path if t > 0]
# charge once
assert len(charge_at) == 1
cs, charging_time = charge_at[0]
cs_coefficient = map_graph.nodes[cs][CHARGING_COEFFICIENT_KEY]
nodes = [n for n, _ in result.charge_path]
distance = sum([map_graph.edges[u, v][HAVERSINE_KEY]
for u, v in zip(nodes[:-1], nodes[1:])])
total_consumption = distance * consumption
# What has been charged equals what is necessary to reach the goal
assert round(total_consumption - mu_s + mu_t) == round(cs_coefficient * charging_time)
# Charge about 10 min
assert charge_at[0] < 600
assert charge_at[0] > 500
assert charging_time < 600
assert charging_time > 500
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