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

fixes import statements

parent 1eae3ebb
Branches
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
import pandas as pd
import matplotlib.pyplot as plt
```
%% Cell type:code id: tags:
``` python
config = 'bigger_gasstation'
```
%% Cell type:code id: tags:
``` python
paths = [
('gasstation', './results/example/queries/gasstation.csv'),
('astar', './results/example/queries/astar.csv'),
('charge', './results/example/queries/charge.csv'),
('classic', './results/example/queries/classic.csv'),
('gasstation', f'./results/{config}/queries/gasstation.csv'),
('astar', f'./results/{config}/queries/astar.csv'),
('charge', f'./results/{config}/queries/charge.csv'),
('classic', f'./results/{config}/queries/classic.csv'),
]
```
%% Cell type:code id: tags:
``` python
datasets = {
name:pd.read_csv(path,dtype={'start_node': str, 'target_node': str}
) for name, path in paths
}
```
%% Cell type:markdown id: tags:
### Average Query Time over n Random Queries
%% Cell type:code id: tags:
``` python
print('n = ', len(list(datasets.values())[0]))
```
%% Output
n = 100
n = 50
%% Cell type:code id: tags:
``` python
fig = plt.figure()
y = []
yerr = []
for df in datasets.values():
y.append(df['query_time'].mean())
yerr.append(df['query_time'].std())
plt.bar(range(len(y)), y, yerr=yerr)
plt.xticks(range(len(y)), [n for n in datasets.keys()])
plt.show()
```
%% Output
%% Cell type:markdown id: tags:
### Separated by Map Size
%% Cell type:code id: tags:
``` python
```
%% Cell type:markdown id: tags:
### Separated by Dijkstra Rank
%% Cell type:code id: tags:
``` python
```
%% Cell type:markdown id: tags:
### Detailed Insight into Gasstation Query Times
%% Cell type:code id: tags:
``` python
gasstation = datasets['gasstation']
gasstation.head()
```
%% Output
start_node target_node query_time trip_time nodes edges \
0 574449274 7286181351 0.015019 194.81357670348197 2827 5691
1 1830470692 7115183094 0.013064 365.0701651885908 2827 5691
2 1672267516 7286240205 0.019652 365.4259696245748 2827 5691
3 2608429637 7030625396 0.013394 145.49989157996416 2827 5691
4 646729136 2604683547 0.014606 329.1692377041301 2827 5691
charging_stations time_contracted_graph time_state_graph
0 3 0.012099 0.000150
1 3 0.011355 0.000133
2 3 0.011933 0.000147
3 3 0.011491 0.000133
4 3 0.011617 0.000133
%% Cell type:code id: tags:
``` python
pure_querys = gasstation['query_time'] - gasstation['time_contracted_graph'] - gasstation['time_state_graph']
y = [pure_querys.mean(), gasstation['time_contracted_graph'].mean(), gasstation['time_state_graph'].mean()]
yerr = [pure_querys.std(), gasstation['time_contracted_graph'].std(), gasstation['time_state_graph'].std()]
fig = plt.figure()
plt.bar(range(len(y)), y, yerr=yerr)
plt.xticks(range(len(y)), ['Kürzester Pfad auf Zustandsgraph', 'Kontraktion', 'Zustandsgraph'])
plt.show()
```
%% Output
%% Cell type:code id: tags:
``` python
```
......
from typing import TextIO
from dataclasses import asdict, fields
from lib.T import QueryRow
from evaluation.lib.T import QueryRow
SEP = ','
......
......@@ -3,7 +3,6 @@ from time import perf_counter
import networkx as nx
from evrouting.T import Result
from evrouting import gasstation, charge
from evrouting.graph_tools import (
consumption_function_distance_factory,
......@@ -13,14 +12,14 @@ from evrouting.graph_tools import (
from evrouting.osm.profiles import car
from evrouting.osm.routing import GasstationAccessFunctions, a_start_heuristic
from lib.T import (
from evaluation.lib.T import (
GasstationQueryRow,
ChargeQueryRow,
ClassicQueryRow,
AStarQueryRow,
QueryRow
)
from lib.algorithm import ranked_dijkstra
from evaluation.lib.algorithm import ranked_dijkstra
__all__ = [
'gasstation_query',
......
import argparse
import json
import gc
import random
import pickle
import logging
......@@ -8,9 +9,9 @@ from pathlib import Path
import yaml
from evrouting.osm.imports import read_osm
from lib.T import *
from lib.export import write_head, write_row
from lib.queries import (
from evaluation.lib.T import *
from evaluation.lib.export import write_head, write_row
from evaluation.lib.queries import (
gasstation_query,
charge_query,
classic_query,
......@@ -22,6 +23,22 @@ from lib.queries import (
base = Path(__file__).parent
def no_gc(func):
"""Run func without garbage collection."""
def inner(*args, **kwargs):
gcold = gc.isenabled()
gc.disable()
try:
r = func(*args, **kwargs)
finally:
if gcold:
gc.enable()
return r
return inner
def query_benchmark(graphs, conf, result_dir):
# Charging Stations
cs_path = base.joinpath('static').joinpath(conf['charging_stations'])
......@@ -64,9 +81,13 @@ def query_benchmark(graphs, conf, result_dir):
map_name
))
for i, (s, t) in enumerate(zip(start_nodes, target_nodes)):
logging.info(f'{i + 1}/{len(start_nodes)}')
logging.debug(f'{i + 1}/{len(start_nodes)}')
# Run tests with garbage collection disabled
result_data = no_gc(func)(G, setup, s, t)
with result_dir.joinpath(filename).open('a') as f:
write_row(f, func(G, setup, s, t))
write_row(f, result_data)
# Delete cached graphs
for key in list(CACHE.keys()):
......@@ -121,6 +142,7 @@ if __name__ == '__main__':
format='%(asctime)s %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p',
level=logging.DEBUG)
results_dir = base.joinpath('results')
static_dir = base.joinpath('static')
maps_dir = static_dir.joinpath('maps')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment