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
56e13140
Commit
56e13140
authored
5 years ago
by
markn92
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
f67a350b
No related branches found
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
+5
-7
5 additions, 7 deletions
evrouting/charge/routing.py
evrouting/charge/utils.py
+6
-7
6 additions, 7 deletions
evrouting/charge/utils.py
with
11 additions
and
14 deletions
evrouting/charge/routing.py
+
5
−
7
View file @
56e13140
from
typing
import
Dict
,
Union
,
Se
t
from
typing
import
Dict
,
Lis
t
from
math
import
inf
import
networkx
as
nx
from
evrouting.T
import
Node
,
SoC
,
Time
from
evrouting.T
import
Node
,
SoC
from
evrouting.utils
import
PriorityQueue
from
evrouting.charge.factories
import
(
ChargingFunctionMap
,
...
...
@@ -11,11 +11,9 @@ from evrouting.charge.factories import (
)
from
..graph_tools
import
distance
from
.T
import
ChargingFunction
,
SoCFunction
,
Label
from
.T
import
SoCFunction
,
Label
from
.utils
import
LabelPriorityQueue
,
keys
__all__
=
[
'
shortest_path
'
]
def
shortest_path
(
G
:
nx
.
Graph
,
charging_stations
:
set
,
s
:
Node
,
t
:
Node
,
initial_soc
:
SoC
,
final_soc
:
SoC
,
capacity
:
SoC
):
...
...
@@ -45,7 +43,7 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
soc_profile_factory
=
SoCProfileFactory
(
G
,
capacity
)
# Init maps to manage labels
l_set
:
Dict
[
int
,
Se
t
[
Label
]]
=
{
v
:
set
()
for
v
in
G
}
l_set
:
Dict
[
int
,
Lis
t
[
Label
]]
=
{
v
:
[]
for
v
in
G
}
l_uns
:
Dict
[
int
,
LabelPriorityQueue
]
=
{
v
:
LabelPriorityQueue
(
f_soc_factory
,
l_set
[
v
])
for
v
in
G
}
...
...
@@ -74,7 +72,7 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
node_min
:
Node
=
prio_queue
.
peak_min
()
label_node_min
:
Label
=
l_uns
[
node_min
].
delete_min
()
l_set
[
node_min
].
a
d
d
(
label_node_min
)
l_set
[
node_min
].
a
ppen
d
(
label_node_min
)
if
node_min
==
t
:
return
f_soc_factory
(
label_node_min
).
minimum
...
...
This diff is collapsed.
Click to expand it.
evrouting/charge/utils.py
+
6
−
7
View file @
56e13140
from
typing
import
Set
,
Any
,
Dict
from
typing
import
Any
,
Dict
,
List
from
math
import
inf
from
evrouting.utils
import
PriorityQueue
...
...
@@ -9,10 +9,10 @@ from .factories import SoCFunctionFactory
class
LabelPriorityQueue
(
PriorityQueue
):
def
__init__
(
self
,
f_soc
:
SoCFunctionFactory
,
l_set
:
Se
t
[
Label
]):
def
__init__
(
self
,
f_soc
:
SoCFunctionFactory
,
l_set
:
Lis
t
[
Label
]):
super
().
__init__
()
self
.
f_soc_factory
:
SoCFunctionFactory
=
f_soc
self
.
l_set
:
Se
t
[
Label
]
=
l_set
self
.
l_set
:
Lis
t
[
Label
]
=
l_set
def
insert
(
self
,
label
:
Label
):
"""
Breaking ties with lowest soc at t_min.
"""
...
...
@@ -34,10 +34,9 @@ class LabelPriorityQueue(PriorityQueue):
soc
=
self
.
f_soc_factory
(
label
)
for
other_label
in
self
.
l_set
:
if
self
.
f_soc_factory
(
other_label
)
>
soc
:
self
.
remove_item
(
label
)
return
# Remove item if it gets dominanted by any label in l_set
if
any
(
self
.
f_soc_factory
(
label
)
>
soc
for
label
in
self
.
l_set
):
self
.
remove_item
(
label
)
def
keys
(
f_soc
:
SoCFunction
)
->
Dict
:
...
...
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