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

adding t

parent 6b964b6b
No related branches found
No related tags found
No related merge requests found
...@@ -69,9 +69,26 @@ def insert_final_node(t: Node, ...@@ -69,9 +69,26 @@ def insert_final_node(t: Node,
gas_stations: Set[Node], gas_stations: Set[Node],
graph_extended: nx.DiGraph, graph_extended: nx.DiGraph,
capacity: SoC, capacity: SoC,
initial_soc: SoC, final_soc: SoC,
dist: DistFunction = dijkstra dist: DistFunction = dijkstra
) -> nx.DiGraph: ) -> nx.DiGraph:
for u in gas_stations:
shortest_p = dist(graph_core, t, u, weight=CONSUMPTION_KEY)
w = fold_path(graph_core, shortest_p, weight=CONSUMPTION_KEY)
if w + final_soc > capacity:
continue
d_u_t = fold_path(graph_core, shortest_p, weight=DISTANCE_KEY)
c_u = charging_cofficient(graph_core, u)
for g in [g for n, g in graph_extended.nodes if n == u]:
if g > w + final_soc:
continue
graph_extended.add_edge(
(u, g),
(t, final_soc),
weight=(w + final_soc - g) * c_u + d_u_t
)
return graph_extended return graph_extended
......
...@@ -282,14 +282,14 @@ class TestIntegration: ...@@ -282,14 +282,14 @@ class TestIntegration:
) )
@pytest.fixture @pytest.fixture
def inserted_t(self, inserted_s, graph_config): def inserted_t(self, inserted_s, contracted_graph, graph_config):
return insert_final_node( return insert_final_node(
t=3, t=3,
graph_core=graph_config['G'], graph_core=graph_config['G'],
gas_stations=graph_config['charging_stations'], gas_stations=graph_config['charging_stations'],
graph_extended=inserted_s, graph_extended=inserted_s,
capacity=graph_config['capacity'], capacity=graph_config['capacity'],
initial_soc=4 final_soc=0
) )
def test_contracted_graph(self, contracted_graph): def test_contracted_graph(self, contracted_graph):
......
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