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):
])
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()):
......
......@@ -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,
......
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment