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

wip

parent 0e90839e
No related branches found
No related tags found
No related merge requests found
from typing import Callable
from math import inf
import networkx as nx
from evrouting.T import Node, SoC
from evrouting.utils import PriorityQueue
from .T import SoCProfile
def shortest_path(G: nx.Graph, s, t, b_0: float, b_t: float, U: float):
def shortest_path(G: nx.Graph, S: set, s: Node, t: Node, beta_s: SoC, beta_t: SoC, U: SoC):
"""
Calculates shortest path using the CHarge algorithm.
:param G: Input Graph
:param s: Start Node identifier
:param t: End Node identifier
:param b_0: Start SoC
:param b_t: End SoC
:param beta_s: Start SoC
:param beta_t: End SoC
:param U: Capacity
:return:
"""
q = PriorityQueue()
l_set = {v: set() for v in G}
l_uns = {v: PriorityQueue() for v in G}
v_0: Node = Node(len(G.nodes))
G.add_node(v_0)
S.add(v_0)
cf_v_0 = [(0, beta_s)]
l_uns[s] = PriorityQueue()
l_uns[s].insert((0, beta_s, v_0, WHAT), 0)
q.insert(s, 0)
# run main loop
while True:
try:
v = q.peak_min()
except KeyError:
# empty queue
break
l = l_uns[v].delete_min()
l_set[v].add(l)
if v == t:
return t_min(f(l))
# handle charging stations
t_trip, beta_u, u, b_u_v = l
if v in S and not v == u:
for t_charge in t_breaks(l):
l_uns[v].insert(new_label(l), priority=) # prio??
# update priority queue
if l_uns[v]:
l_new = l_uns[v].peak_min()
q.insert(v, key(l_new))
else:
q.delete_min()
# scan outgoing arcs
for x, y in G[v]:
b_x_y = link(beta_u_v, create_b(G, x, y))
if not b_x_y(beta_max_u) == -inf:
l_new = (t_trip + G.edges[x, y]['weight'], beta_u, u, b_x_y)
l_uns[y].insert(l_new)
if l_new == l_uns[y].peak_min():
q.insert(y, key(l_new))
def link(beta: SoCProfile, b_func: SoCProfile) -> SoCProfile:
pass
def creade_b(G: nx.Graph, x: Node, y: Node) -> SoCProfile:
pass
def key(label):
pass
def f(label):
pass
def t_min(f):
pass
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