From dbbd88d1fe09cdd64d586037ff05f3f25f54f73e Mon Sep 17 00:00:00 2001 From: "niehues.mark@gmail.com" <niehues.mark@gmail.com> Date: Thu, 7 May 2020 12:23:51 +0200 Subject: [PATCH] minor --- evaluation/lib/benchmarks.py | 28 ++++++++++++---------------- evaluation/lib/queries.py | 6 ------ evaluation/run.py | 7 ++++++- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/evaluation/lib/benchmarks.py b/evaluation/lib/benchmarks.py index 14b4d6a..6ff017a 100644 --- a/evaluation/lib/benchmarks.py +++ b/evaluation/lib/benchmarks.py @@ -139,6 +139,9 @@ def init(graphs, charging_stations, conf, result_dir): ]) 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']: # Random adding of charging stations @@ -149,22 +152,15 @@ def init(graphs, charging_stations, conf, result_dir): with result_dir.joinpath(filename).open('a') as f: write_row(f, result_data) - # little hacky: get just created state graph from module cache - state_graph, _ = queries.CACHE[queries._cache_state_graph_key] - if len(state_graph.nodes) > 2: - # random start and target nodes of state graph - nodes = random.sample(list(state_graph.nodes), k=2 * conf['queries_per_setup']) - start_nodes = nodes[:int(len(nodes) / 2)] - target_nodes = nodes[int(len(nodes) / 2):] - - _run_queries( - G, - start_nodes, - target_nodes, - setup, - [queries.insert_nodes_into_state_graph], - result_dir - ) + # random start and target nodes of state graph + _run_queries( + G, + start_nodes, + target_nodes, + setup, + [queries.insert_nodes_into_state_graph], + result_dir + ) # Delete cached graphs for key in list(queries.CACHE.keys()): diff --git a/evaluation/lib/queries.py b/evaluation/lib/queries.py index 0a7a62c..618e131 100644 --- a/evaluation/lib/queries.py +++ b/evaluation/lib/queries.py @@ -159,12 +159,6 @@ def init_gasstation_queries(graph, conf): contracted_graph, contraction_time = get_contracted_graph(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( charging_stations=len(graph.charging_stations), time_contracted_graph=contraction_time, diff --git a/evaluation/run.py b/evaluation/run.py index e122465..0fb15ae 100644 --- a/evaluation/run.py +++ b/evaluation/run.py @@ -63,12 +63,17 @@ if __name__ == '__main__': nargs='+' ) + r = base.joinpath('results') + r.mkdir(exist_ok=True) + args = parser.parse_args() path: Path 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) + logging.info(f'Processing {path}..') + path = path.with_suffix('.yaml') with base.joinpath('configs/', path).open() as f: -- GitLab