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

debugging

parent 4d5e4167
No related branches found
No related tags found
No related merge requests found
......@@ -8,3 +8,4 @@ dist
*.osm
mapcache
evaluation/results
stats*.csv
import json
import logging.config
import pickle
import os
from time import perf_counter
from evrouting.osm.imports import OSMGraph
from evrouting import charge
......@@ -29,23 +31,58 @@ def main():
mu_s = 40000
mu_t = 0
capacity = 40000
s = '274939401'
t = '299642186'
print(f'Solving {s} to {t}..')
start = perf_counter()
charge.routing.shortest_path(
G=G,
charging_stations=G.charging_stations,
s=s,
t=t,
initial_soc=mu_s,
final_soc=mu_t,
capacity=capacity,
c=c
)
runtime = perf_counter() - start
tasks = [
('2600400888', '2364151130'),
('274939401', '299642186')
]
for i, (s, t) in enumerate(tasks):
print(f'Solving {s} to {t}..')
start = perf_counter()
charge.routing.shortest_path(
G=G,
charging_stations=G.charging_stations,
s=s,
t=t,
initial_soc=mu_s,
final_soc=mu_t,
capacity=capacity,
c=c
)
runtime = perf_counter() - start
try:
os.rename('stats.csv', f'stats{i}.csv')
except FileExistsError:
os.remove('fstats{i}.csv')
os.rename('stats.csv', f'stats{i}.csv')
def get_logging_config():
return {
'version': 1,
'formatters': {
'plain': {
'fmt': '%(message)s'
}
},
'handlers': {
'file': {
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'plain',
'mode': 'w',
'filename': 'stats.csv'
}
},
'loggers': {
'stats': {
'level': 'DEBUG',
'propagate': 0,
'handlers': ['file']
}
}
}
if __name__ == '__main__':
logging.config.dictConfig(get_logging_config())
main()
......@@ -5,8 +5,8 @@ description: >
paths:
charging_stations: charging_stations.json
map: medium_nurnberg.osm
queries_per_rank: 20
ranks: [6, 8, 10, 12, 14, 18]
queries_per_rank: 1
ranks: [6, 8, 10, 12, 14, 18, 20, 22]
algorithms: [charge]
mu_s: 40 # Start and Target Soc
mu_t: 0
......
......@@ -7,6 +7,7 @@ Implementation of the CHArge algorithm [0] with two further constraints:
[0] https://dl.acm.org/doi/10.1145/2820783.2820826
"""
import logging
from typing import Dict, List, Tuple, Set
from math import inf
......@@ -22,6 +23,8 @@ from evrouting.charge.factories import (
SoCProfileFactory
)
logger = logging.getLogger('stats')
def shortest_path(G: nx.DiGraph, charging_stations: Set[Node], s: Node, t: Node,
initial_soc: SoC, final_soc: SoC, capacity: SoC, c=consumption) -> Result:
......@@ -60,11 +63,13 @@ def shortest_path(G: nx.DiGraph, charging_stations: Set[Node], s: Node, t: Node,
# Shortcut for key function
keys = LabelPriorityQueue.keys
logger.debug('t_min,soc_min')
while prio_queue:
node_min: Node = prio_queue.peak_min()
label_node_min: Label = l_uns[node_min].delete_min()
logger.debug('{priority},{count}'.format(
**keys(f_soc_factory(label_node_min))))
l_set[node_min].append(label_node_min)
if node_min == t:
......@@ -131,6 +136,8 @@ def shortest_path(G: nx.DiGraph, charging_stations: Set[Node], s: Node, t: Node,
try:
is_new_min: bool = label_neighbour == l_uns[n].peak_min()
except KeyError:
# Hasn't been inserted into l_uns because it was dominated
# by a label in l_set
continue
if is_new_min:
......
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