Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ba
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
markn92
ba
Commits
31033f25
Commit
31033f25
authored
5 years ago
by
markn92
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
0e90839e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
evrouting/charge/routing.py
+80
-3
80 additions, 3 deletions
evrouting/charge/routing.py
with
80 additions
and
3 deletions
evrouting/charge/routing.py
+
80
−
3
View file @
31033f25
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 b
eta_s
: Start SoC
:param b
eta
_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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment