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

gasstation query stats

parent baed1393
No related branches found
No related tags found
No related merge requests found
......@@ -5,12 +5,12 @@ type: query
charging_stations: charging_stations.json
maps:
- map.osm
querys_per_setup: 10
queries_per_setup: 10
setups:
- mu_s: capacity # Start and Target Soc
- mu_s: 85 # Start and Target Soc
mu_t: 0
charging_stations: 10 # Max Number of charging Stations to be inserted.
capactiy: 85 # kWh
capacity: 85 # kWh
consumption:
type: gasstation
consumption_coefficient: 100 # kWh/s
......@@ -12,4 +12,4 @@ def write_head(f: TextIO, row_class: QueryRow):
def write_row(f: TextIO, row: QueryRow):
f.write(SEP.join(asdict(row).values()) + "\n")
f.write(SEP.join([str(i) for i in asdict(row).values()]) + "\n")
from time import perf_counter
from evaluation.export import write_row
from evaluation.T import (
GasstationQueryRow,
......@@ -6,23 +8,70 @@ from evaluation.T import (
AStarQueryRow
)
from evrouting.T import Result
from evrouting import gasstation, charge
from evrouting.osm.routing import GasstationAccessFunctions
__all__ = ['gasstation_query', 'charge_query', 'classic_query', 'astar_query']
def gasstation_query(graph, conf, file):
pass
def gasstation_query(graph, conf, s, t, file):
f = GasstationAccessFunctions(conf['consumption']['consumption_coefficient'])
start = perf_counter()
contracted_graph = gasstation.routing.contract_graph(
G=graph,
charging_stations=graph.charging_stations,
capacity=conf['capacity'],
f=f
)
contraction_time = perf_counter() - start
start = perf_counter()
state_graph = gasstation.routing.state_graph(
contracted_graph,
conf['capacity'],
f
)
state_graph_time = perf_counter() - start
start = perf_counter()
result = gasstation.routing.shortest_path(
G=graph,
charging_stations=graph.charging_stations,
s=s,
t=t,
initial_soc=conf['mu_s'],
final_soc=conf['mu_t'],
capacity=conf['capacity'],
f=f,
extended_graph=state_graph,
contracted_graph=contracted_graph
)
query_time = perf_counter() - start
row = GasstationQueryRow(
start_node=s,
target_node=t,
query_time=query_time,
trip_time=result.trip_time if type(result) == Result else None,
nodes=len(graph.nodes),
edges=len(graph.edges),
charging_stations=len(graph.charging_stations),
time_contracted_graph=contraction_time,
time_state_graph=state_graph_time
)
write_row(file, row)
def charge_query(graph, conf, file):
def charge_query(graph, conf, s, t, file):
pass
def classic_query(graph, conf, file):
def classic_query(graph, conf, s, t, file):
pass
def astar_query(graph, conf, file):
def astar_query(graph, conf, s, t, file):
pass
start_node,target_node,query_time,trip_time,nodes,edges,charging_stations,time_contracted_graph,time_state_graph
549931430,3273201464,0.02408712999749696,None,2827,5691,3,0.014958268002374098,3.0371003958862275e-05
2729891690,6603016874,0.02328153499547625,None,2827,5691,3,0.01450053900043713,3.0627001251559705e-05
34053773,408478843,0.03271863699774258,None,2827,5691,3,0.014691472999402322,1.9122999219689518e-05
292981057,4955446070,0.029121861000021454,None,2827,5691,3,0.01552509299654048,2.008400042541325e-05
1254599554,360747579,0.017258337000384927,None,2827,5691,3,0.014459179998084437,1.8801998521666974e-05
6389441586,508824243,0.016824515005282592,None,2827,5691,3,0.015478776003874373,1.987600262509659e-05
7042580410,1929118248,0.04107918299996527,None,2827,5691,3,0.01451436200295575,1.9384002371225506e-05
7074500856,7140363786,0.03340997399936896,None,2827,5691,3,0.014721665997058153,1.9647995941340923e-05
360747732,4955446065,0.026879377001023386,None,2827,5691,3,0.016268585000943858,1.9888000679202378e-05
600866946,4016874580,0.02424645799328573,None,2827,5691,3,0.0144769019971136,2.0027000573463738e-05
import argparse
import json
import random
from pathlib import Path
import yaml
......@@ -14,7 +15,7 @@ from evaluation.queries import *
def query_benchmark(graphs,
conf,
result_dir):
QUERIES = [
query_conf = [
Query(query_function=gasstation_query,
filename='gasstation.csv',
row_dataclass=GasstationQueryRow),
......@@ -24,10 +25,16 @@ def query_benchmark(graphs,
]
for G in graphs:
for func, filename, row_class in QUERIES:
with result_dir.joinpath(filename).open('w') as f:
write_head(f, row_class)
func(G, conf, f)
nodes = random.choices(list(G.nodes), k=2 * conf['queries_per_setup'])
for setup in conf['setups']:
start_nodes = nodes[:int(len(nodes) / 2)]
target_nodes = nodes[int(len(nodes) / 2):]
for func, filename, row_class in query_conf:
with result_dir.joinpath(filename).open('w') as f:
write_head(f, row_class)
for s, t in zip(start_nodes, target_nodes):
func(G, setup, s, t, f)
def get_map(osm_path: Path, cs_path: Path):
......
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