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
f67a350b
"git@git.imp.fu-berlin.de:podlesny/dune-faultnetworks.git" did not exist on "d00ed834e458d812f6b75fe05310f90f435aa132"
Commit
f67a350b
authored
5 years ago
by
markn92
Browse files
Options
Downloads
Patches
Plain Diff
minor change
parent
258a96eb
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
+25
-23
25 additions, 23 deletions
evrouting/charge/routing.py
with
25 additions
and
23 deletions
evrouting/charge/routing.py
+
25
−
23
View file @
f67a350b
...
@@ -46,7 +46,9 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
...
@@ -46,7 +46,9 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
# Init maps to manage labels
# Init maps to manage labels
l_set
:
Dict
[
int
,
Set
[
Label
]]
=
{
v
:
set
()
for
v
in
G
}
l_set
:
Dict
[
int
,
Set
[
Label
]]
=
{
v
:
set
()
for
v
in
G
}
l_uns
:
Dict
[
int
,
LabelPriorityQueue
]
=
{
v
:
LabelPriorityQueue
(
f_soc_factory
,
l_set
[
v
])
for
v
in
G
}
l_uns
:
Dict
[
int
,
LabelPriorityQueue
]
=
{
v
:
LabelPriorityQueue
(
f_soc_factory
,
l_set
[
v
])
for
v
in
G
}
# Add dummy charging station with charging function
# Add dummy charging station with charging function
# cf(t) = initial_soc (ie charging coefficient is zero).
# cf(t) = initial_soc (ie charging coefficient is zero).
...
@@ -69,28 +71,28 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
...
@@ -69,28 +71,28 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
prio_queue
.
insert
(
s
,
priority
=
0
,
count
=
0
)
prio_queue
.
insert
(
s
,
priority
=
0
,
count
=
0
)
while
prio_queue
:
while
prio_queue
:
minimum_
node
:
Node
=
prio_queue
.
peak_min
()
node
_min
:
Node
=
prio_queue
.
peak_min
()
label_
minimum_
node
:
Label
=
l_uns
[
minimum_
node
].
delete_min
()
label_node
_min
:
Label
=
l_uns
[
node
_min
].
delete_min
()
l_set
[
minimum_node
].
add
(
label_minimum_node
)
l_set
[
node_min
].
add
(
label_node_min
)
if
minimum_
node
==
t
:
if
node
_min
==
t
:
return
f_soc_factory
(
label_
minimum_
node
).
minimum
return
f_soc_factory
(
label_node
_min
).
minimum
# Handle charging stations
# Handle charging stations
if
minimum_
node
in
charging_stations
and
\
if
node
_min
in
charging_stations
and
\
not
minimum_node
==
label_minimum_node
.
last_cs
:
not
node_min
==
label_node_min
.
last_cs
:
f_soc
:
SoCFunction
=
f_soc_factory
(
label_
minimum_
node
)
f_soc
:
SoCFunction
=
f_soc_factory
(
label_node
_min
)
t_charge
=
f_soc
.
calc_optimal_t_charge
(
cf_map
[
minimum_
node
])
t_charge
=
f_soc
.
calc_optimal_t_charge
(
cf_map
[
node
_min
])
if
t_charge
is
not
None
:
if
t_charge
is
not
None
:
# Spawn new label at t_charge
# Spawn new label at t_charge
l_uns
[
minimum_
node
].
insert
(
l_uns
[
node
_min
].
insert
(
Label
(
Label
(
t_trip
=
label_
minimum_
node
.
t_trip
+
t_charge
,
t_trip
=
label_node
_min
.
t_trip
+
t_charge
,
soc_last_cs
=
f_soc
(
label_
minimum_
node
.
t_trip
+
t_charge
),
soc_last_cs
=
f_soc
(
label_node
_min
.
t_trip
+
t_charge
),
last_cs
=
minimum_
node
,
last_cs
=
node
_min
,
soc_profile_cs_v
=
soc_profile_factory
(
minimum_
node
)
soc_profile_cs_v
=
soc_profile_factory
(
node
_min
)
)
)
)
)
...
@@ -98,24 +100,24 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
...
@@ -98,24 +100,24 @@ def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node,
# minimum label spawned is th previous step.
# minimum label spawned is th previous step.
try
:
try
:
prio_queue
.
insert
(
prio_queue
.
insert
(
item
=
minimum_
node
,
item
=
node
_min
,
**
keys
(
f_soc_factory
(
l_uns
[
minimum_
node
].
peak_min
()))
**
keys
(
f_soc_factory
(
l_uns
[
node
_min
].
peak_min
()))
)
)
except
KeyError
:
except
KeyError
:
# l_uns[v] empty
# l_uns[v] empty
prio_queue
.
delete_min
()
prio_queue
.
delete_min
()
# scan outgoing arcs
# scan outgoing arcs
for
n
in
G
.
neighbors
(
minimum_
node
):
for
n
in
G
.
neighbors
(
node
_min
):
# Create SoC Profile for getting from minimum_node to n
# Create SoC Profile for getting from minimum_node to n
soc_profile
=
label_
minimum_
node
.
soc_profile_cs_v
+
\
soc_profile
=
label_node
_min
.
soc_profile_cs_v
+
\
soc_profile_factory
(
minimum_
node
,
n
)
soc_profile_factory
(
node
_min
,
n
)
if
soc_profile
(
capacity
)
!=
-
inf
:
if
soc_profile
(
capacity
)
!=
-
inf
:
l_new
=
Label
(
l_new
=
Label
(
t_trip
=
label_
minimum_
node
.
t_trip
+
distance
(
G
,
minimum_
node
,
n
),
t_trip
=
label_node
_min
.
t_trip
+
distance
(
G
,
node
_min
,
n
),
soc_last_cs
=
label_
minimum_
node
.
soc_last_cs
,
soc_last_cs
=
label_node
_min
.
soc_last_cs
,
last_cs
=
label_
minimum_
node
.
last_cs
,
last_cs
=
label_node
_min
.
last_cs
,
soc_profile_cs_v
=
soc_profile
soc_profile_cs_v
=
soc_profile
)
)
try
:
try
:
...
...
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