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

minor

parent 67553cc1
No related branches found
No related tags found
No related merge requests found
...@@ -139,6 +139,9 @@ def init(graphs, charging_stations, conf, result_dir): ...@@ -139,6 +139,9 @@ def init(graphs, charging_stations, conf, result_dir):
]) ])
for map_name, G in zip(conf['maps'], graphs): for map_name, G in zip(conf['maps'], graphs):
nodes = random.sample(list(G.nodes), k=2 * conf['queries_per_setup'])
start_nodes = nodes[:int(len(nodes) / 2)]
target_nodes = nodes[int(len(nodes) / 2):]
for setup in conf['setups']: for setup in conf['setups']:
# Random adding of charging stations # Random adding of charging stations
...@@ -149,22 +152,15 @@ def init(graphs, charging_stations, conf, result_dir): ...@@ -149,22 +152,15 @@ def init(graphs, charging_stations, conf, result_dir):
with result_dir.joinpath(filename).open('a') as f: with result_dir.joinpath(filename).open('a') as f:
write_row(f, result_data) write_row(f, result_data)
# little hacky: get just created state graph from module cache # random start and target nodes of state graph
state_graph, _ = queries.CACHE[queries._cache_state_graph_key] _run_queries(
if len(state_graph.nodes) > 2: G,
# random start and target nodes of state graph start_nodes,
nodes = random.sample(list(state_graph.nodes), k=2 * conf['queries_per_setup']) target_nodes,
start_nodes = nodes[:int(len(nodes) / 2)] setup,
target_nodes = nodes[int(len(nodes) / 2):] [queries.insert_nodes_into_state_graph],
result_dir
_run_queries( )
G,
start_nodes,
target_nodes,
setup,
[queries.insert_nodes_into_state_graph],
result_dir
)
# Delete cached graphs # Delete cached graphs
for key in list(queries.CACHE.keys()): for key in list(queries.CACHE.keys()):
......
...@@ -159,12 +159,6 @@ def init_gasstation_queries(graph, conf): ...@@ -159,12 +159,6 @@ def init_gasstation_queries(graph, conf):
contracted_graph, contraction_time = get_contracted_graph(graph, conf, f) contracted_graph, contraction_time = get_contracted_graph(graph, conf, f)
state_graph, state_graph_time = get_state_graph(contracted_graph, conf, f) state_graph, state_graph_time = get_state_graph(contracted_graph, conf, f)
"""
start = perf_counter()
nx.shortest_path(state_graph, s, t)
runtime = perf_counter() - start
"""
return InitQueryRow( return InitQueryRow(
charging_stations=len(graph.charging_stations), charging_stations=len(graph.charging_stations),
time_contracted_graph=contraction_time, time_contracted_graph=contraction_time,
......
...@@ -63,12 +63,17 @@ if __name__ == '__main__': ...@@ -63,12 +63,17 @@ if __name__ == '__main__':
nargs='+' nargs='+'
) )
r = base.joinpath('results')
r.mkdir(exist_ok=True)
args = parser.parse_args() args = parser.parse_args()
path: Path path: Path
for path in args.configs: for path in args.configs:
benchmark_dir = base.joinpath('results', path.with_suffix('')) benchmark_dir = r.joinpath(path.with_suffix(''))
benchmark_dir.mkdir(exist_ok=True) benchmark_dir.mkdir(exist_ok=True)
logging.info(f'Processing {path}..')
path = path.with_suffix('.yaml') path = path.with_suffix('.yaml')
with base.joinpath('configs/', path).open() as f: with base.joinpath('configs/', path).open() as f:
......
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