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
fabb001c
Commit
fabb001c
authored
5 years ago
by
markn92
Browse files
Options
Downloads
Patches
Plain Diff
add bool function to queue
parent
2cfd3e35
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
evrouting/charge/routing.py
+4
-7
4 additions, 7 deletions
evrouting/charge/routing.py
evrouting/utils.py
+9
-0
9 additions, 0 deletions
evrouting/utils.py
with
13 additions
and
7 deletions
evrouting/charge/routing.py
+
4
−
7
View file @
fabb001c
...
@@ -52,12 +52,8 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
...
@@ -52,12 +52,8 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
prio_queue
=
PriorityQueue
()
prio_queue
=
PriorityQueue
()
prio_queue
.
insert
(
s
,
priority
=
0
,
count
=
0
)
prio_queue
.
insert
(
s
,
priority
=
0
,
count
=
0
)
while
True
:
while
prio_queue
:
try
:
minimum_node
:
Node
=
prio_queue
.
peak_min
()
minimum_node
:
Node
=
prio_queue
.
peak_min
()
except
KeyError
:
# empty queue
break
label_minimum_node
:
Label
=
l_uns
[
minimum_node
].
delete_min
()
label_minimum_node
:
Label
=
l_uns
[
minimum_node
].
delete_min
()
l_set
[
minimum_node
].
add
(
label_minimum_node
)
l_set
[
minimum_node
].
add
(
label_minimum_node
)
...
@@ -65,7 +61,7 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
...
@@ -65,7 +61,7 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
if
minimum_node
==
t
:
if
minimum_node
==
t
:
return
f_soc_factory
(
label_minimum_node
).
minimum
return
f_soc_factory
(
label_minimum_node
).
minimum
#
h
andle charging stations
#
H
andle charging stations
if
minimum_node
in
charging_stations
and
\
if
minimum_node
in
charging_stations
and
\
not
minimum_node
==
label_minimum_node
.
last_cs
:
not
minimum_node
==
label_minimum_node
.
last_cs
:
f_soc
:
SoCFunction
=
f_soc_factory
(
label_minimum_node
)
f_soc
:
SoCFunction
=
f_soc_factory
(
label_minimum_node
)
...
@@ -75,6 +71,7 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
...
@@ -75,6 +71,7 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
capacity
=
capacity
)
capacity
=
capacity
)
if
t_charge
is
not
None
:
if
t_charge
is
not
None
:
# Spawn new label at t_charge
l_uns
[
minimum_node
].
insert
(
l_uns
[
minimum_node
].
insert
(
Label
(
Label
(
t_trip
=
label_minimum_node
.
t_trip
+
t_charge
,
t_trip
=
label_minimum_node
.
t_trip
+
t_charge
,
...
...
This diff is collapsed.
Click to expand it.
evrouting/utils.py
+
9
−
0
View file @
fabb001c
...
@@ -48,3 +48,12 @@ class PriorityQueue:
...
@@ -48,3 +48,12 @@ class PriorityQueue:
else
:
else
:
heappop
(
self
.
pq
)
heappop
(
self
.
pq
)
raise
KeyError
(
'
Empty queue.
'
)
raise
KeyError
(
'
Empty queue.
'
)
def
__bool__
(
self
)
->
bool
:
"""
Check if empty.
"""
try
:
self
.
peak_min
()
except
KeyError
:
return
False
return
True
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