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
805eeea4
Commit
805eeea4
authored
4 years ago
by
markn92
Browse files
Options
Downloads
Patches
Plain Diff
adding t
parent
6b964b6b
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/gasstation/routing.py
+18
-1
18 additions, 1 deletion
evrouting/gasstation/routing.py
tests/gasstation/test_transformations.py
+2
-2
2 additions, 2 deletions
tests/gasstation/test_transformations.py
with
20 additions
and
3 deletions
evrouting/gasstation/routing.py
+
18
−
1
View file @
805eeea4
...
@@ -69,9 +69,26 @@ def insert_final_node(t: Node,
...
@@ -69,9 +69,26 @@ def insert_final_node(t: Node,
gas_stations
:
Set
[
Node
],
gas_stations
:
Set
[
Node
],
graph_extended
:
nx
.
DiGraph
,
graph_extended
:
nx
.
DiGraph
,
capacity
:
SoC
,
capacity
:
SoC
,
in
iti
al_soc
:
SoC
,
f
inal_soc
:
SoC
,
dist
:
DistFunction
=
dijkstra
dist
:
DistFunction
=
dijkstra
)
->
nx
.
DiGraph
:
)
->
nx
.
DiGraph
:
for
u
in
gas_stations
:
shortest_p
=
dist
(
graph_core
,
t
,
u
,
weight
=
CONSUMPTION_KEY
)
w
=
fold_path
(
graph_core
,
shortest_p
,
weight
=
CONSUMPTION_KEY
)
if
w
+
final_soc
>
capacity
:
continue
d_u_t
=
fold_path
(
graph_core
,
shortest_p
,
weight
=
DISTANCE_KEY
)
c_u
=
charging_cofficient
(
graph_core
,
u
)
for
g
in
[
g
for
n
,
g
in
graph_extended
.
nodes
if
n
==
u
]:
if
g
>
w
+
final_soc
:
continue
graph_extended
.
add_edge
(
(
u
,
g
),
(
t
,
final_soc
),
weight
=
(
w
+
final_soc
-
g
)
*
c_u
+
d_u_t
)
return
graph_extended
return
graph_extended
...
...
This diff is collapsed.
Click to expand it.
tests/gasstation/test_transformations.py
+
2
−
2
View file @
805eeea4
...
@@ -282,14 +282,14 @@ class TestIntegration:
...
@@ -282,14 +282,14 @@ class TestIntegration:
)
)
@pytest.fixture
@pytest.fixture
def
inserted_t
(
self
,
inserted_s
,
graph_config
):
def
inserted_t
(
self
,
inserted_s
,
contracted_graph
,
graph_config
):
return
insert_final_node
(
return
insert_final_node
(
t
=
3
,
t
=
3
,
graph_core
=
graph_config
[
'
G
'
],
graph_core
=
graph_config
[
'
G
'
],
gas_stations
=
graph_config
[
'
charging_stations
'
],
gas_stations
=
graph_config
[
'
charging_stations
'
],
graph_extended
=
inserted_s
,
graph_extended
=
inserted_s
,
capacity
=
graph_config
[
'
capacity
'
],
capacity
=
graph_config
[
'
capacity
'
],
in
iti
al_soc
=
4
f
inal_soc
=
0
)
)
def
test_contracted_graph
(
self
,
contracted_graph
):
def
test_contracted_graph
(
self
,
contracted_graph
):
...
...
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