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

caching intermediate graphs

parent d6551e29
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ type: query ...@@ -5,7 +5,7 @@ type: query
charging_stations: charging_stations.json charging_stations: charging_stations.json
maps: maps:
- map.osm - map.osm
queries_per_setup: 100 queries_per_setup: 10
setups: setups:
- mu_s: 300 # Start and Target Soc - mu_s: 300 # Start and Target Soc
mu_t: 0 mu_t: 0
......
import logging
from time import perf_counter from time import perf_counter
import networkx as nx import networkx as nx
...@@ -18,12 +19,35 @@ from lib.T import ( ...@@ -18,12 +19,35 @@ from lib.T import (
AStarQueryRow AStarQueryRow
) )
__all__ = ['gasstation_query', 'charge_query', 'classic_query', 'astar_query'] __all__ = [
'gasstation_query',
'charge_query',
'classic_query',
'astar_query'
]
CACHE = {}
def gasstation_query(graph, conf, s, t):
f = GasstationAccessFunctions(conf['consumption']['consumption_coefficient'])
def cached(key):
"""Cache returned graph to file in temp_dir."""
def decorator(func):
def getter(*args, **kwargs):
try:
return CACHE[key], None
except KeyError:
graph, runtime = func(*args, **kwargs)
CACHE[key] = graph
return graph, runtime
return getter
return decorator
@cached('gasstation')
def get_contracted_graph(graph, conf, f):
start = perf_counter() start = perf_counter()
contracted_graph = gasstation.routing.contract_graph( contracted_graph = gasstation.routing.contract_graph(
G=graph, G=graph,
...@@ -32,7 +56,15 @@ def gasstation_query(graph, conf, s, t): ...@@ -32,7 +56,15 @@ def gasstation_query(graph, conf, s, t):
f=f f=f
) )
contraction_time = perf_counter() - start contraction_time = perf_counter() - start
logging.info('Contracted graph with {} stations in {:.2f} s.'.format(
len(graph.charging_stations),
contraction_time
))
return contracted_graph, contraction_time
@cached('state_graph')
def get_state_graph(contracted_graph, conf, f):
start = perf_counter() start = perf_counter()
state_graph = gasstation.routing.state_graph( state_graph = gasstation.routing.state_graph(
contracted_graph, contracted_graph,
...@@ -40,6 +72,16 @@ def gasstation_query(graph, conf, s, t): ...@@ -40,6 +72,16 @@ def gasstation_query(graph, conf, s, t):
f f
) )
state_graph_time = perf_counter() - start state_graph_time = perf_counter() - start
logging.info('Created State Graph in {:.2f} s.'.format(
state_graph_time
))
return state_graph, state_graph_time
def gasstation_query(graph, conf, s, t):
f = GasstationAccessFunctions(conf['consumption']['consumption_coefficient'])
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() start = perf_counter()
result = gasstation.routing.shortest_path( result = gasstation.routing.shortest_path(
...@@ -59,7 +101,7 @@ def gasstation_query(graph, conf, s, t): ...@@ -59,7 +101,7 @@ def gasstation_query(graph, conf, s, t):
return GasstationQueryRow( return GasstationQueryRow(
start_node=s, start_node=s,
target_node=t, target_node=t,
query_time=query_time + contraction_time + state_graph_time, query_time=query_time,
trip_time=result.trip_time if type(result) == Result else None, trip_time=result.trip_time if type(result) == Result else None,
nodes=len(graph.nodes), nodes=len(graph.nodes),
edges=len(graph.edges), edges=len(graph.edges),
......
start_node,target_node,query_time,trip_time,nodes,edges,charging_stations start_node,target_node,query_time,trip_time,nodes,edges,charging_stations
7321902574,318014974,0.007568578999780584,238.1110904996911,2827,5691,3 418009800,574457854,0.016365269000743865,513.3867017835531,2827,5691,1
4016874515,2611369730,0.003537241000231006,113.40853811212274,2827,5691,3 1934189643,1672267862,0.024794959999780986,None,2827,5691,1
7182110441,268980011,0.006901079999806825,575.546920845741,2827,5691,3 4955445788,2608597329,0.006531982999149477,468.61012521592113,2827,5691,1
1934188724,34911575,0.02502793900021061,None,2827,5691,3 3111465599,426948327,0.02325725999980932,733.6313989681807,2827,5691,1
1867147194,549947326,0.009264481999707641,306.3977004462799,2827,5691,3 426930250,360747525,0.010435072001200751,730.4096032452347,2827,5691,1
418009253,1411856646,0.024911561000408255,926.5828722425748,2827,5691,3 2626105675,574449298,0.015268628001649631,581.5878060414734,2827,5691,1
6448459754,2608429407,0.005626917999506986,110.63446581791817,2827,5691,3 2608501851,418009810,0.009202822999213822,311.5216253485141,2827,5691,1
1821291294,318261953,0.009873198999230226,366.3184015404222,2827,5691,3 1718397716,294919195,0.00783049699930416,316.4427340861574,2827,5691,1
1927634061,360747579,0.012953817000379786,465.50083809477644,2827,5691,3 405229458,748845494,0.007164475000536186,241.74032174316505,2827,5691,1
79954921,2614897354,0.011293107000710734,626.9765430725013,2827,5691,3 5726327175,5576939249,0.005316733000654494,133.7762557564627,2827,5691,1
1934189119,563194918,0.002633582000271417,243.91394290107357,2827,5691,3 start_node,target_node,query_time,trip_time,nodes,edges,charging_stations
408478784,2614897352,0.004225145999953384,376.06559393330286,2827,5691,3 418009800,574457854,0.01609230000030948,513.3867017835531,2827,5691,2
3111465595,474997347,0.005856654999661259,233.37360027751848,2827,5691,3 1934189643,1672267862,0.02513524099958886,None,2827,5691,2
1672267587,7115310188,7.70900005591102e-05,None,2827,5691,3 4955445788,2608597329,0.006504785998913576,468.61012521592113,2827,5691,2
426948340,2623041441,0.017265800000132003,607.4759695626486,2827,5691,3 3111465599,426948327,0.02274821399987559,733.6313989681807,2827,5691,2
7030602777,2614920443,0.011115194000012707,309.14324380214833,2827,5691,3 426930250,360747525,0.010359958001572522,730.4096032452347,2827,5691,2
2611494658,7074500839,0.02345366000008653,649.6622428768856,2827,5691,3 2626105675,574449298,0.015497483000217471,581.5878060414734,2827,5691,2
6448461998,2604687802,0.010816668999723333,369.2373455358261,2827,5691,3 2608501851,418009810,0.009121514000071329,311.5216253485141,2827,5691,2
317767227,748845499,0.02000224200037337,438.7724254643551,2827,5691,3 1718397716,294919195,0.007242572999530239,316.4427340861574,2827,5691,2
7081828735,1757613834,0.017728652999721817,638.132348548364,2827,5691,3 405229458,748845494,0.0071749509988876525,241.74032174316505,2827,5691,2
600861362,34053452,0.0033281639998676837,257.2835741707556,2827,5691,3 5726327175,5576939249,0.00539905000005092,133.7762557564627,2827,5691,2
7030623427,5609334121,0.009842467999988003,505.63577043459526,2827,5691,3 start_node,target_node,query_time,trip_time,nodes,edges,charging_stations
793260945,1935264851,0.02548328200009564,982.3373940665655,2827,5691,3 418009800,574457854,0.01592524300031073,513.3867017835531,2827,5691,3
2616315923,7257113601,0.004644349000045622,232.54030844332127,2827,5691,3 1934189643,1672267862,0.0248023820004164,None,2827,5691,3
1827520762,426930253,0.02144544400016457,555.1219663447,2827,5691,3 4955445788,2608597329,0.006321331999060931,468.61012521592113,2827,5691,3
2997117857,45217462,0.0007760219996271189,239.69584582112356,2827,5691,3 3111465599,426948327,0.023352963999059284,733.6313989681807,2827,5691,3
7074500836,318015069,0.006032391999724496,358.3313926632318,2827,5691,3 426930250,360747525,0.010226640999462688,730.4096032452347,2827,5691,3
1672334351,2997117873,0.014431023999350145,619.7320443863234,2827,5691,3 2626105675,574449298,0.015081085999554489,581.5878060414734,2827,5691,3
5113940071,574546136,0.00032739900052547455,38.36680561831532,2827,5691,3 2608501851,418009810,0.00919760700162442,311.5216253485141,2827,5691,3
3307706662,408478842,0.0002016809994529467,106.17669377184302,2827,5691,3 1718397716,294919195,0.007316459999856306,316.4427340861574,2827,5691,3
365065394,2619115981,0.004220568000164349,211.22096795741354,2827,5691,3 405229458,748845494,0.0069069710007170215,241.74032174316505,2827,5691,3
2973923689,2604686273,0.004096565000509145,314.30553801234936,2827,5691,3 5726327175,5576939249,0.005275892001009197,133.7762557564627,2827,5691,3
5576943376,549938448,0.012980622999748448,378.7504835821481,2827,5691,3
7140363797,4475752956,0.006811612999626959,405.1173694042988,2827,5691,3
2608501043,549944087,0.006625901999541384,309.83263677334804,2827,5691,3
7115183094,1821291310,0.006649093999840261,166.72662919095825,2827,5691,3
4016874408,469720334,0.014832183000180521,474.5248341109552,2827,5691,3
7115183090,508823959,0.003660451000541798,99.25054650686562,2827,5691,3
2598984220,2639898818,0.007726304999778222,315.22936375978804,2827,5691,3
1934189313,34053448,0.01874155099994823,996.5041118441444,2827,5691,3
306639025,2608786068,0.005269233000035456,335.3712680198829,2827,5691,3
549931420,2635713653,0.019543730000805226,443.3356339909103,2827,5691,3
1929118250,7246644040,0.023990942000637006,792.7725145604651,2827,5691,3
474997344,321209230,0.008237455999733356,360.1032536260311,2827,5691,3
4383156579,318014986,0.006319156999779807,334.8287484267631,2827,5691,3
2701786796,7321902570,0.014290217000052508,396.4678926102016,2827,5691,3
418009817,408478815,0.006516372000078263,393.2077751296899,2827,5691,3
665115010,7180800494,0.005075002000012319,121.99627562066787,2827,5691,3
7286240204,7207579520,0.012112248000448744,444.57943336659633,2827,5691,3
7286240202,3273201483,0.0034503960005167755,151.17570520208938,2827,5691,3
34053458,1672267572,0.012001237999356817,534.9695327831129,2827,5691,3
6448461991,1827520765,0.025130322999757482,None,2827,5691,3
2600451785,2705157134,0.0119646510001985,391.70762990375385,2827,5691,3
1672267690,306639024,0.00011611700028879568,None,2827,5691,3
317767228,574482753,0.013925289000326302,360.4443894533518,2827,5691,3
6448461999,317839537,0.001202407000164385,113.79275358739032,2827,5691,3
45217495,3996162743,0.016943106999860902,370.86620593338074,2827,5691,3
288947123,7030602775,0.0084678539997185,380.7827532273404,2827,5691,3
318260942,1672267832,0.02540487199985364,None,2827,5691,3
4955446038,6603016874,0.008938343999943754,338.336413426195,2827,5691,3
1574635372,7140363795,0.0005431959998531966,None,2827,5691,3
2611404223,1636935570,0.01713199500045448,477.29034631823833,2827,5691,3
7182110439,45217473,0.007642070000656531,588.6851099661361,2827,5691,3
7115244209,418009812,0.014710782999827643,389.59809435549516,2827,5691,3
2604685993,288944217,0.019526024999322544,517.7769043458792,2827,5691,3
2600670536,665115005,0.002605667000352696,346.37375978016064,2827,5691,3
306636853,426948333,0.022952964000069187,572.6741026406311,2827,5691,3
7165728796,549947346,0.010273412999595166,397.60081105225186,2827,5691,3
34053442,79952473,0.004863211000156298,159.72842896428756,2827,5691,3
549943303,292484626,0.02529727199998888,None,2827,5691,3
1672334374,2621462848,0.004323944000134361,685.7706435103163,2827,5691,3
574485683,45217441,0.004481981999560958,214.6046386679047,2827,5691,3
1826594887,549931434,0.01306698200005485,436.26736948173607,2827,5691,3
7321870098,6389435552,0.0045035630000711535,164.6141667563423,2827,5691,3
7115244215,4016874494,0.0021844929997314466,59.16033555162781,2827,5691,3
2335713764,2611369851,0.008659335999254836,341.4414664124244,2827,5691,3
2884684292,1828418192,0.005371036999349599,227.3872947428237,2827,5691,3
2608394380,79952469,0.004148380000515317,323.70435471590326,2827,5691,3
574485682,408478827,0.004000263000307314,186.9543818851861,2827,5691,3
4955446039,2591134812,0.02313379499992152,623.3082344539869,2827,5691,3
292981056,5576939244,0.00780612100061262,350.8540660979972,2827,5691,3
2635713647,1820309645,0.0035686840001289966,158.25319591694605,2827,5691,3
6047068261,549941827,0.006793865999497939,238.57914333266365,2827,5691,3
2616315927,2611492275,0.00995773199974792,364.99875612623697,2827,5691,3
79952492,430534359,0.012335537000581098,404.07151199153935,2827,5691,3
7245276253,674511702,0.011887880000358564,361.98526836465845,2827,5691,3
7115244212,4225277008,0.011752117000469298,346.17073362608573,2827,5691,3
7286240209,408478755,0.023824191999665345,731.529341557396,2827,5691,3
574546108,1830468180,0.023124328000449168,692.7399479939606,2827,5691,3
600858466,1827520830,0.02558539399979054,None,2827,5691,3
4226442916,549925965,0.017318748999969102,458.86593644477375,2827,5691,3
2627469510,600866945,0.002440263000607956,169.10426681490915,2827,5691,3
1672267773,4955446069,0.00013917000069341157,None,2827,5691,3
2608597627,288944214,0.009315194000009797,320.059571405044,2827,5691,3
418009820,318015012,0.006670095000117726,376.9674794697233,2827,5691,3
7158827509,1828263557,0.006894396999996388,265.2832428627522,2827,5691,3
7115126884,418009264,0.010392732000582328,331.629702693991,2827,5691,3
574465009,5609333816,0.015511605999563471,429.3442689028079,2827,5691,3
3123285391,2611369895,0.006960386000173457,213.00699592380232,2827,5691,3
574482746,549941210,0.00527424699976109,207.27982913832062,2827,5691,3
start_node,target_node,query_time,trip_time,nodes,edges,charging_stations start_node,target_node,query_time,trip_time,nodes,edges,charging_stations
7321902574,318014974,0.816606456000045,1792.648905540409,2828,5691,3 418009800,574457854,0.33510476099945663,None,2828,5691,1
4016874515,2611369730,0.05695069000012154,113.40853811212274,2827,5691,3 1934189643,1672267862,0.012840351999329869,None,2827,5691,1
7182110441,268980011,0.023140358999626187,None,2828,5691,3 4955445788,2608597329,0.01045286299995496,None,2828,5691,1
1934188724,34911575,0.32412717399984103,None,2827,5691,3 3111465599,426948327,0.42038153800058353,None,2827,5691,1
1867147194,549947326,1.0531797159992493,None,2828,5691,3 426930250,360747525,0.03632907799874374,None,2828,5691,1
418009253,1411856646,0.023896833999970113,None,2827,5691,3 2626105675,574449298,0.16826632900119876,None,2827,5691,1
6448459754,2608429407,0.08569430400075362,110.63446581791817,2828,5691,3 2608501851,418009810,0.28878574400005164,311.5216253485141,2828,5691,1
1821291294,318261953,0.8421148419993187,9576.358960120844,2827,5691,3 1718397716,294919195,0.588220438999997,19410.47441813424,2827,5691,1
1927634061,360747579,0.7470106589998977,None,2828,5691,3 405229458,748845494,0.14829701700000442,241.74032174316505,2828,5691,1
79954921,2614897354,0.01227395899968542,None,2827,5691,3 5726327175,5576939249,0.11976762000085728,133.7762557564627,2827,5691,1
1934189119,563194918,0.07671072499942966,243.91394290107357,2828,5691,3 start_node,target_node,query_time,trip_time,nodes,edges,charging_stations
408478784,2614897352,0.09311294800045289,None,2827,5691,3 418009800,574457854,0.33343001899993396,None,2828,5691,2
3111465595,474997347,0.2229279070006669,233.37360027751848,2828,5691,3 1934189643,1672267862,0.012630760998945334,None,2827,5691,2
1672267587,7115310188,0.012990934000299603,None,2827,5691,3 4955445788,2608597329,0.010600056000839686,None,2828,5691,2
426948340,2623041441,0.03597513000022445,None,2828,5691,3 3111465599,426948327,0.429355864000172,None,2827,5691,2
7030602777,2614920443,0.42990678400019533,None,2827,5691,3 426930250,360747525,0.03632738200030872,None,2828,5691,2
2611494658,7074500839,0.6106054279998716,None,2828,5691,3 2626105675,574449298,0.17084869800055458,None,2827,5691,2
6448461998,2604687802,0.7877546489999077,None,2827,5691,3 2608501851,418009810,0.29104091499903006,311.5216253485141,2828,5691,2
317767227,748845499,0.5888809139996738,None,2828,5691,3 1718397716,294919195,0.5826008940002794,19410.47441813424,2827,5691,2
7081828735,1757613834,0.2787895599994954,None,2827,5691,3 405229458,748845494,0.14460836600119364,241.74032174316505,2828,5691,2
600861362,34053452,0.1160973930000182,257.2835741707556,2828,5691,3 5726327175,5576939249,0.11788628400063317,133.7762557564627,2827,5691,2
7030623427,5609334121,0.2116003549999732,19699.075181768025,2827,5691,3 start_node,target_node,query_time,trip_time,nodes,edges,charging_stations
793260945,1935264851,0.4287361090000559,None,2828,5691,3 418009800,574457854,0.3407406269998319,None,2828,5691,3
2616315923,7257113601,0.1145265790000849,232.54030844332127,2827,5691,3 1934189643,1672267862,0.01283182599945576,None,2827,5691,3
1827520762,426930253,0.21864520799954335,None,2828,5691,3 4955445788,2608597329,0.010952074000670109,None,2828,5691,3
2997117857,45217462,0.011323332999381819,239.69584582112356,2827,5691,3 3111465599,426948327,0.754869055999734,None,2827,5691,3
7074500836,318015069,0.24373853799988865,18499.671678755098,2828,5691,3 426930250,360747525,0.03519974899973022,None,2828,5691,3
1672334351,2997117873,0.006136222000350244,None,2827,5691,3 2626105675,574449298,0.33222086900059367,None,2827,5691,3
5113940071,574546136,0.0067075360002490925,38.36680561831532,2828,5691,3 2608501851,418009810,0.3017630939993978,311.5216253485141,2828,5691,3
3307706662,408478842,0.006063058000108867,106.17669377184302,2827,5691,3 1718397716,294919195,0.6059926620000624,19410.47441813424,2827,5691,3
365065394,2619115981,0.08204879600089043,211.22096795741354,2828,5691,3 405229458,748845494,0.17973764000089432,241.74032174316505,2828,5691,3
2973923689,2604686273,0.055503057000350964,314.30553801234936,2827,5691,3 5726327175,5576939249,0.11767219800094608,133.7762557564627,2827,5691,3
5576943376,549938448,0.8836931559999357,None,2828,5691,3
7140363797,4475752956,0.009287233000577544,None,2827,5691,3
2608501043,549944087,0.9896497019999515,None,2828,5691,3
7115183094,1821291310,0.16703532399969845,166.72662919095825,2827,5691,3
4016874408,469720334,0.6323797390004984,None,2828,5691,3
7115183090,508823959,0.07809145000010176,99.25054650686562,2827,5691,3
2598984220,2639898818,0.1919862570002806,317.989681778846,2828,5691,3
1934189313,34053448,0.062292321999848355,None,2827,5691,3
306639025,2608786068,0.03854399600004399,None,2828,5691,3
549931420,2635713653,0.45712342700062436,None,2827,5691,3
1929118250,7246644040,0.5446669550001388,None,2828,5691,3
474997344,321209230,0.5101050759994905,25721.375123146114,2827,5691,3
4383156579,318014986,0.2736173040002541,15552.042241115294,2828,5691,3
2701786796,7321902570,0.44951088200014055,None,2827,5691,3
418009817,408478815,0.3063651310003479,None,2828,5691,3
665115010,7180800494,0.13378255800034822,121.99627562066787,2827,5691,3
7286240204,7207579520,0.7944291719995817,None,2828,5691,3
7286240202,3273201483,0.10878032700020412,151.17570520208938,2827,5691,3
34053458,1672267572,0.018573579999610956,None,2828,5691,3
6448461991,1827520765,0.4178299609993701,None,2827,5691,3
2600451785,2705157134,0.295613293000315,None,2828,5691,3
1672267690,306639024,0.029936169999928097,None,2827,5691,3
317767228,574482753,0.5675544059995445,None,2828,5691,3
6448461999,317839537,0.0191387830000167,113.79275358739032,2827,5691,3
45217495,3996162743,0.9394159049998052,None,2828,5691,3
288947123,7030602775,0.33305940499940334,None,2827,5691,3
318260942,1672267832,0.3947207510000226,None,2828,5691,3
4955446038,6603016874,0.5525475649992586,None,2827,5691,3
1574635372,7140363795,0.0061973400006536394,None,2828,5691,3
2611404223,1636935570,1.0060662539999612,None,2827,5691,3
7182110439,45217473,0.025666359999377164,None,2828,5691,3
7115244209,418009812,0.9239453850004793,None,2827,5691,3
2604685993,288944217,2.4160380559997066,None,2828,5691,3
2600670536,665115005,0.08823915300035878,346.37375978016064,2827,5691,3
306636853,426948333,0.8456364619996748,None,2828,5691,3
7165728796,549947346,1.1368291119997593,None,2827,5691,3
34053442,79952473,0.11454584500006604,159.72842896428756,2828,5691,3
549943303,292484626,0.3857124339992879,None,2827,5691,3
1672334374,2621462848,0.005592903999968257,None,2828,5691,3
574485683,45217441,0.09150863600007142,214.6046386679047,2827,5691,3
1826594887,549931434,0.4621335629999521,None,2828,5691,3
7321870098,6389435552,0.13617897600033757,164.6141667563423,2827,5691,3
7115244215,4016874494,0.04243734299961943,59.16033555162781,2828,5691,3
2335713764,2611369851,0.24678136299917242,18481.74054420309,2827,5691,3
2884684292,1828418192,0.25409771999966324,227.45445690314511,2828,5691,3
2608394380,79952469,0.1772169229998326,323.70435471590326,2827,5691,3
574485682,408478827,0.06435229900034756,186.9543818851861,2828,5691,3
4955446039,2591134812,0.5674075529996117,None,2827,5691,3
292981056,5576939244,0.3297397569995155,None,2828,5691,3
2635713647,1820309645,0.11047373000019434,158.25319591694605,2827,5691,3
6047068261,549941827,0.1659991420001461,238.57914333266365,2828,5691,3
2616315927,2611492275,0.35699719700005517,None,2827,5691,3
79952492,430534359,0.7037360610001997,None,2828,5691,3
7245276253,674511702,0.48892663400056335,2965.5782504425006,2827,5691,3
7115244212,4225277008,0.4287897479998719,None,2828,5691,3
7286240209,408478755,0.8902888889997485,None,2827,5691,3
574546108,1830468180,56.450571792999654,None,2828,5691,3
600858466,1827520830,0.705039191000651,None,2827,5691,3
4226442916,549925965,0.7127105130002747,None,2828,5691,3
2627469510,600866945,0.08905787500043516,169.10426681490915,2827,5691,3
1672267773,4955446069,0.004978612000741123,None,2828,5691,3
2608597627,288944214,0.8749616969998897,7241.99317190265,2827,5691,3
418009820,318015012,0.07547216999955708,376.9674794697233,2828,5691,3
7158827509,1828263557,0.12232587600010447,265.2832428627522,2827,5691,3
7115126884,418009264,0.7031070630000613,None,2828,5691,3
574465009,5609333816,0.372224918000029,None,2827,5691,3
3123285391,2611369895,0.13805532100013806,213.00699592380232,2828,5691,3
574482746,549941210,0.09052957499989134,207.27982913832062,2827,5691,3
start_node,target_node,query_time,trip_time,nodes,edges,charging_stations,dijkstra_rank start_node,target_node,query_time,trip_time,nodes,edges,charging_stations,dijkstra_rank
7321902574,318014974,0.002519671999834827,238.1110904996911,2827,5691,3,0 418009800,574457854,0.004828957000427181,513.3867017835531,2827,5691,1,0
4016874515,2611369730,0.0011238140004934394,113.40853811212274,2827,5691,3,0 1934189643,1672267862,0.005808068000987987,None,2827,5691,1,0
7182110441,268980011,0.001713784000457963,575.546920845741,2827,5691,3,0 4955445788,2608597329,0.001732140999592957,468.61012521592113,2827,5691,1,0
1934188724,34911575,0.005819557999529934,None,2827,5691,3,0 3111465599,426948327,0.005730105000111507,733.6313989681807,2827,5691,1,0
1867147194,549947326,0.0037802899996677297,306.3977004462799,2827,5691,3,0 426930250,360747525,0.002913627000452834,730.4096032452347,2827,5691,1,0
418009253,1411856646,0.005890318000638217,926.5828722425748,2827,5691,3,0 2626105675,574449298,0.004262749000190524,581.5878060414734,2827,5691,1,0
6448459754,2608429407,0.0015214900004139054,110.63446581791817,2827,5691,3,0 2608501851,418009810,0.0028825260014855303,311.5216253485141,2827,5691,1,0
1821291294,318261953,0.003146213999571046,366.3184015404222,2827,5691,3,0 1718397716,294919195,0.002073088999168249,316.4427340861574,2827,5691,1,0
1927634061,360747579,0.006537439000567247,465.50083809477644,2827,5691,3,0 405229458,748845494,0.0025266470001952257,241.74032174316505,2827,5691,1,0
79954921,2614897354,0.0034732479998638155,626.9765430725013,2827,5691,3,0 5726327175,5576939249,0.0016190309997909935,133.7762557564627,2827,5691,1,0
1934189119,563194918,0.0007917940001789248,243.91394290107357,2827,5691,3,0 start_node,target_node,query_time,trip_time,nodes,edges,charging_stations,dijkstra_rank
408478784,2614897352,0.0015355779996752972,376.06559393330286,2827,5691,3,0 418009800,574457854,0.004759720000947709,513.3867017835531,2827,5691,2,0
3111465595,474997347,0.0017485260004832526,233.37360027751848,2827,5691,3,0 1934189643,1672267862,0.005909605999477208,None,2827,5691,2,0
1672267587,7115310188,2.4167999981727917e-05,None,2827,5691,3,0 4955445788,2608597329,0.001711437000267324,468.61012521592113,2827,5691,2,0
426948340,2623041441,0.00504699500015704,607.4759695626486,2827,5691,3,0 3111465599,426948327,0.005789236000055098,733.6313989681807,2827,5691,2,0
7030602777,2614920443,0.004175713999757136,309.14324380214833,2827,5691,3,0 426930250,360747525,0.0029222049997770227,730.4096032452347,2827,5691,2,0
2611494658,7074500839,0.006150950999654015,649.6622428768856,2827,5691,3,0 2626105675,574449298,0.004599191001034342,581.5878060414734,2827,5691,2,0
6448461998,2604687802,0.0036673259992312524,369.2373455358261,2827,5691,3,0 2608501851,418009810,0.003021403001184808,311.5216253485141,2827,5691,2,0
317767227,748845499,0.005325655999513401,438.7724254643551,2827,5691,3,0 1718397716,294919195,0.002083249999486725,316.4427340861574,2827,5691,2,0
7081828735,1757613834,0.004511068000283558,638.132348548364,2827,5691,3,0 405229458,748845494,0.002550164001149824,241.74032174316505,2827,5691,2,0
600861362,34053452,0.0018471389994374476,257.2835741707556,2827,5691,3,0 5726327175,5576939249,0.001533010999992257,133.7762557564627,2827,5691,2,0
7030623427,5609334121,0.0023055800002111937,505.63577043459526,2827,5691,3,0 start_node,target_node,query_time,trip_time,nodes,edges,charging_stations,dijkstra_rank
793260945,1935264851,0.006104363999838824,982.3373940665655,2827,5691,3,0 418009800,574457854,0.004621473999577574,513.3867017835531,2827,5691,3,0
2616315923,7257113601,0.001763603000654257,232.54030844332127,2827,5691,3,0 1934189643,1672267862,0.005740635999245569,None,2827,5691,3,0
1827520762,426930253,0.007004467000115255,555.1219663447,2827,5691,3,0 4955445788,2608597329,0.0018071670001518214,468.61012521592113,2827,5691,3,0
2997117857,45217462,0.0002233479999631527,239.69584582112356,2827,5691,3,0 3111465599,426948327,0.005631329000607366,733.6313989681807,2827,5691,3,0
7074500836,318015069,0.0019508490004227497,358.3313926632318,2827,5691,3,0 426930250,360747525,0.0028826800007664133,730.4096032452347,2827,5691,3,0
1672334351,2997117873,0.005116002999784541,619.7320443863234,2827,5691,3,0 2626105675,574449298,0.004391055999803939,581.5878060414734,2827,5691,3,0
5113940071,574546136,0.00014604399984818883,38.36680561831532,2827,5691,3,0 2608501851,418009810,0.0030651209999632556,311.5216253485141,2827,5691,3,0
3307706662,408478842,9.085800047614612e-05,106.17669377184302,2827,5691,3,0 1718397716,294919195,0.0022838530003355118,316.4427340861574,2827,5691,3,0
365065394,2619115981,0.0015626829999746406,211.22096795741354,2827,5691,3,0 405229458,748845494,0.0025572689992259257,241.74032174316505,2827,5691,3,0
2973923689,2604686273,0.0013597130000562174,314.30553801234936,2827,5691,3,0 5726327175,5576939249,0.0016318019988830201,133.7762557564627,2827,5691,3,0
5576943376,549938448,0.003950379999878351,378.7504835821481,2827,5691,3,0
7140363797,4475752956,0.001974978000362171,405.1173694042988,2827,5691,3,0
2608501043,549944087,0.002876131999983045,309.83263677334804,2827,5691,3,0
7115183094,1821291310,0.0016394470003433526,166.72662919095825,2827,5691,3,0
4016874408,469720334,0.004805833000318671,474.5248341109552,2827,5691,3,0
7115183090,508823959,0.001090603999728046,99.25054650686562,2827,5691,3,0
2598984220,2639898818,0.0017905220001921407,315.22936375978804,2827,5691,3,0
1934189313,34053448,0.005262915999992401,996.5041118441444,2827,5691,3,0
306639025,2608786068,0.0017418150000594324,335.3712680198829,2827,5691,3,0
549931420,2635713653,0.005793508000351721,443.3356339909103,2827,5691,3,0
1929118250,7246644040,0.005666458999257884,792.7725145604651,2827,5691,3,0
474997344,321209230,0.004416523000145389,360.1032536260311,2827,5691,3,0
4383156579,318014986,0.001728482000544318,334.8287484267631,2827,5691,3,0
2701786796,7321902570,0.004073723000146856,396.4678926102016,2827,5691,3,0
418009817,408478815,0.0022180609994393308,393.2077751296899,2827,5691,3,0
665115010,7180800494,0.0014712470001541078,121.99627562066787,2827,5691,3,0
7286240204,7207579520,0.003412189000300714,444.57943336659633,2827,5691,3,0
7286240202,3273201483,0.0010125459994014818,151.17570520208938,2827,5691,3,0
34053458,1672267572,0.004387083999972674,534.9695327831129,2827,5691,3,0
6448461991,1827520765,0.006571904000338691,None,2827,5691,3,0
2600451785,2705157134,0.00510032400052296,391.70762990375385,2827,5691,3,0
1672267690,306639024,3.9774000470060855e-05,None,2827,5691,3,0
317767228,574482753,0.004602334000082919,360.4443894533518,2827,5691,3,0
6448461999,317839537,0.00046482899961119983,113.79275358739032,2827,5691,3,0
45217495,3996162743,0.005132786000103806,370.86620593338074,2827,5691,3,0
288947123,7030602775,0.0030040209994695033,380.7827532273404,2827,5691,3,0
318260942,1672267832,0.0074371099999552825,None,2827,5691,3,0
4955446038,6603016874,0.0030983750002633315,338.336413426195,2827,5691,3,0
1574635372,7140363795,9.686800058261724e-05,None,2827,5691,3,0
2611404223,1636935570,0.004732641999908083,477.29034631823833,2827,5691,3,0
7182110439,45217473,0.0033237799998460105,588.6851099661361,2827,5691,3,0
7115244209,418009812,0.004428059000019857,389.59809435549516,2827,5691,3,0
2604685993,288944217,0.005145299000105297,517.7769043458792,2827,5691,3,0
2600670536,665115005,0.0010103529994012206,346.37375978016064,2827,5691,3,0
306636853,426948333,0.005547469000703131,572.6741026406311,2827,5691,3,0
7165728796,549947346,0.0029472710002664826,397.60081105225186,2827,5691,3,0
34053442,79952473,0.0013936549994468805,159.72842896428756,2827,5691,3,0
549943303,292484626,0.005738058999668283,None,2827,5691,3,0
1672334374,2621462848,0.0015659170003345935,685.7706435103163,2827,5691,3,0
574485683,45217441,0.0011523289995238883,214.6046386679047,2827,5691,3,0
1826594887,549931434,0.0038064310001573176,436.26736948173607,2827,5691,3,0
7321870098,6389435552,0.001359501000479213,164.6141667563423,2827,5691,3,0
7115244215,4016874494,0.0006750539996573934,59.16033555162781,2827,5691,3,0
2335713764,2611369851,0.0022982750006121933,341.4414664124244,2827,5691,3,0
2884684292,1828418192,0.0025121770004261634,227.3872947428237,2827,5691,3,0
2608394380,79952469,0.0017890930002977257,323.70435471590326,2827,5691,3,0
574485682,408478827,0.001031939999847964,186.9543818851861,2827,5691,3,0
4955446039,2591134812,0.005635057000290544,623.3082344539869,2827,5691,3,0
292981056,5576939244,0.0030401649992199964,350.8540660979972,2827,5691,3,0
2635713647,1820309645,0.001137377999839373,158.25319591694605,2827,5691,3,0
6047068261,549941827,0.0016248410001935554,238.57914333266365,2827,5691,3,0
2616315927,2611492275,0.0031081359993549995,364.99875612623697,2827,5691,3,0
79952492,430534359,0.004308175000005576,404.07151199153935,2827,5691,3,0
7245276253,674511702,0.004105555000023742,361.98526836465845,2827,5691,3,0
7115244212,4225277008,0.003819587999714713,346.17073362608573,2827,5691,3,0
7286240209,408478755,0.005415741999968304,731.529341557396,2827,5691,3,0
574546108,1830468180,0.005615375999695971,692.7399479939606,2827,5691,3,0
600858466,1827520830,0.00601139299942588,None,2827,5691,3,0
4226442916,549925965,0.004591696000716183,458.86593644477375,2827,5691,3,0
2627469510,600866945,0.00184673700005078,169.10426681490915,2827,5691,3,0
1672267773,4955446069,3.999399996246211e-05,None,2827,5691,3,0
2608597627,288944214,0.0027223360002608388,320.059571405044,2827,5691,3,0
418009820,318015012,0.0019810060002782848,376.9674794697233,2827,5691,3,0
7158827509,1828263557,0.002145832000678638,265.2832428627522,2827,5691,3,0
7115126884,418009264,0.0031014950000098906,331.629702693991,2827,5691,3,0
574465009,5609333816,0.0041591769995648065,429.3442689028079,2827,5691,3,0
3123285391,2611369895,0.0019373100003576837,213.00699592380232,2827,5691,3,0
574482746,549941210,0.0014043890005268622,207.27982913832062,2827,5691,3,0
start_node,target_node,query_time,trip_time,nodes,edges,charging_stations,time_contracted_graph,time_state_graph start_node,target_node,query_time,trip_time,nodes,edges,charging_stations,time_contracted_graph,time_state_graph
318261951,318261959,0.038180532996193506,172.45882045633869,2827,5691,3,0.037711901000875514,0.00019447699742158875 418009800,574457854,0.016529435999473208,513.3867017835531,2827,5691,1,9.77930012595607e-05,2.879800013033673e-05
1828254502,2600722301,0.03250095799739938,267.023987254795,2827,5691,3,0.030721290000656154,0.0001709889984340407 1934189643,1672267862,0.024617869001303916,None,2827,5691,1,None,None
6448459779,563188710,0.0537844359932933,499.28016704624633,2827,5691,3,0.03073318299720995,0.00015049200010253116 4955445788,2608597329,0.006554030000188504,468.61012521592113,2827,5691,1,None,None
34053445,7030617900,0.03731665799568873,197.60092044964952,2827,5691,3,0.029835863002517726,0.00014812199515290558 3111465599,426948327,0.023431165000147303,733.6313989681807,2827,5691,1,None,None
7140363787,365065389,0.16060936499707168,5289.464871890885,2827,5691,3,0.029732053997577168,0.0001641850030864589 426930250,360747525,0.010238357999696746,730.4096032452347,2827,5691,1,None,None
34053436,574510655,0.13449935099924915,12493.937351844768,2827,5691,3,0.03673829699982889,0.0001338760048383847 2626105675,574449298,0.017239513999811606,581.5878060414734,2827,5691,1,None,None
4016874617,600866945,0.03444541599310469,336.22355324649334,2827,5691,3,0.025150192996079568,0.0001335359993390739 2608501851,418009810,0.009257375000743195,311.5216253485141,2827,5691,1,None,None
2604893830,317840526,0.033937345004233066,309.94330930385564,2827,5691,3,0.030045136001717765,0.00017759900219971314 1718397716,294919195,0.00842110699886689,316.4427340861574,2827,5691,1,None,None
358407314,408478842,0.05122477700206218,401.91530793157204,2827,5691,3,0.037094525003340095,0.00016986099944915622 405229458,748845494,0.007098027999745682,241.74032174316505,2827,5691,1,None,None
7031902220,7413975520,0.05967648500518408,564.4893406225968,2827,5691,3,0.03245272000640398,0.00014979099796619266 5726327175,5576939249,0.005705544999727863,133.7762557564627,2827,5691,1,None,None
7172883308,294919117,0.03263318400422577,170.233971842473,2827,5691,3,0.031021587004943285,0.00014976900274632499 start_node,target_node,query_time,trip_time,nodes,edges,charging_stations,time_contracted_graph,time_state_graph
1253890916,563194893,0.0370539380091941,391.1747845270358,2827,5691,3,0.026461945002665743,0.0001331370003754273 418009800,574457854,0.016138078000949463,513.3867017835531,2827,5691,2,0.004825021000215202,6.158799988043029e-05
2598988057,1718397716,0.07217752800352173,546.5151867025655,2827,5691,3,0.03469335199770285,0.000258364001638256 1934189643,1672267862,0.026505159999942407,None,2827,5691,2,None,None
4033695046,3462099364,0.0765392429966596,407.49923848865484,2827,5691,3,0.05154037800093647,0.00022893399727763608 4955445788,2608597329,0.006831624999904307,468.61012521592113,2827,5691,2,None,None
7031881626,6417387130,0.031294264997995924,156.7057004635975,2827,5691,3,0.02944477099663345,0.00013357999705476686 3111465599,426948327,0.022835116998976446,733.6313989681807,2827,5691,2,None,None
600858466,418009803,0.03277176600386156,338.1322944383446,2827,5691,3,0.024690256999747362,0.000133293004182633 426930250,360747525,0.010438203999001416,730.4096032452347,2827,5691,2,None,None
563191187,600866946,0.03260277200752171,296.72303474174004,2827,5691,3,0.025442889003898017,0.0001829210013966076 2626105675,574449298,0.015608510999300051,581.5878060414734,2827,5691,2,None,None
549943303,110236457,0.19823851800174452,16061.351333843417,2827,5691,3,0.03400557600252796,0.00016302099538734183 2608501851,418009810,0.0089906039993366,311.5216253485141,2827,5691,2,None,None
2360479288,574505822,0.06603433399141068,434.8168387633591,2827,5691,3,0.047148549994744826,0.0002223939955001697 1718397716,294919195,0.007416918999297195,316.4427340861574,2827,5691,2,None,None
549931427,6448462029,0.04602842399617657,282.12944542993813,2827,5691,3,0.039396102001774125,0.00015461699513252825 405229458,748845494,0.007365741999819875,241.74032174316505,2827,5691,2,None,None
34053441,1505992703,0.02921961199172074,105.81963664036086,2827,5691,3,0.027504672994837165,0.0001335929991910234 5726327175,5576939249,0.005357400001230417,133.7762557564627,2827,5691,2,None,None
1656016522,268979982,0.03408875299646752,550.8666195183011,2827,5691,3,0.02586048300145194,0.00013299999409355223 start_node,target_node,query_time,trip_time,nodes,edges,charging_stations,time_contracted_graph,time_state_graph
4955446065,5110912270,0.11530301200400572,None,2827,5691,3,0.028086596001230646,0.00025582600210327655 418009800,574457854,0.016169999000339885,513.3867017835531,2827,5691,3,0.03335488100128714,0.00013285199929669034
1934189643,1672267862,0.024665127999469405,None,2827,5691,3,None,None
4955445788,2608597329,0.006551911999849835,468.61012521592113,2827,5691,3,None,None
3111465599,426948327,0.022852780000903294,733.6313989681807,2827,5691,3,None,None
426930250,360747525,0.01021414099886897,730.4096032452347,2827,5691,3,None,None
2626105675,574449298,0.015425386000060826,581.5878060414734,2827,5691,3,None,None
2608501851,418009810,0.009126294000452617,311.5216253485141,2827,5691,3,None,None
1718397716,294919195,0.007759873000395601,316.4427340861574,2827,5691,3,None,None
405229458,748845494,0.00701812700026494,241.74032174316505,2827,5691,3,None,None
5726327175,5576939249,0.005257716000414803,133.7762557564627,2827,5691,3,None,None
...@@ -10,7 +10,9 @@ import yaml ...@@ -10,7 +10,9 @@ import yaml
from evrouting.osm.imports import read_osm from evrouting.osm.imports import read_osm
from lib.T import * from lib.T import *
from lib.export import write_head, write_row from lib.export import write_head, write_row
from lib.queries import * from lib.queries import (
gasstation_query, charge_query, classic_query, astar_query, CACHE
)
base = Path(__file__).parent base = Path(__file__).parent
...@@ -22,14 +24,21 @@ def query_benchmark(graphs, conf, result_dir): ...@@ -22,14 +24,21 @@ def query_benchmark(graphs, conf, result_dir):
charging_stations = json.load(f) charging_stations = json.load(f)
query_conf = [ query_conf = [
# Query(query_function=gasstation_query, Query(query_function=gasstation_query,
# filename='gasstation.csv', filename='gasstation.csv',
# row_dataclass=GasstationQueryRow), row_dataclass=GasstationQueryRow),
Query(charge_query, 'charge.csv', ChargeQueryRow), Query(charge_query, 'charge.csv', ChargeQueryRow),
Query(classic_query, 'classic.csv', ClassicQueryRow), Query(classic_query, 'classic.csv', ClassicQueryRow),
Query(astar_query, 'astar.csv', AStarQueryRow) Query(astar_query, 'astar.csv', AStarQueryRow)
] ]
# Remove existing results
for _, filename, _ in query_conf:
try:
result_dir.joinpath(filename).unlink()
except FileNotFoundError:
pass
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']) nodes = random.sample(list(G.nodes), k=2 * conf['queries_per_setup'])
for setup in conf['setups']: for setup in conf['setups']:
...@@ -43,11 +52,15 @@ def query_benchmark(graphs, conf, result_dir): ...@@ -43,11 +52,15 @@ def query_benchmark(graphs, conf, result_dir):
func.__name__, func.__name__,
map_name map_name
)) ))
with result_dir.joinpath(filename).open('w') as f: with result_dir.joinpath(filename).open('a') as f:
write_head(f, row_class) write_head(f, row_class)
for s, t in zip(start_nodes, target_nodes): for s, t in zip(start_nodes, target_nodes):
write_row(f, func(G, setup, s, t)) write_row(f, func(G, setup, s, t))
# Delete cached graphs
for key in list(CACHE.keys()):
del CACHE[key]
def insert_charging_stations(graph, number, charging_stations): def insert_charging_stations(graph, number, charging_stations):
start = perf_counter() start = perf_counter()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment