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
4d5e4167
Commit
4d5e4167
authored
4 years ago
by
markn92
Browse files
Options
Downloads
Patches
Plain Diff
makes sense so far
parent
bf73f7e6
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
tests/osm/test_osm_charge.py
+18
-6
18 additions, 6 deletions
tests/osm/test_osm_charge.py
with
18 additions
and
6 deletions
tests/osm/test_osm_charge.py
+
18
−
6
View file @
4d5e4167
...
...
@@ -105,23 +105,35 @@ def test_charge_shortest_route_stop(map_graph):
cost_path
=
6
*
consumption
*
1000
# distance * consumption in Wh
c
=
consumption_function_distance_factory
(
consumption
)
mu_s
=
2000
mu_t
=
0
result
=
charge
.
routing
.
shortest_path
(
G
=
map_graph
,
charging_stations
=
map_graph
.
charging_stations
,
s
=
_s
,
t
=
_t
,
initial_soc
=
2000
,
# > cost_path
final_soc
=
0
,
initial_soc
=
mu_s
,
# > cost_path
final_soc
=
mu_t
,
capacity
=
10000
,
c
=
c
)
assert
type
(
result
)
is
Result
charge_at
=
[
t
for
n
,
t
in
result
.
charge_path
if
t
>
0
]
charge_at
=
[
(
n
,
t
)
for
n
,
t
in
result
.
charge_path
if
t
>
0
]
# charge once
assert
len
(
charge_at
)
==
1
cs
,
charging_time
=
charge_at
[
0
]
cs_coefficient
=
map_graph
.
nodes
[
cs
][
CHARGING_COEFFICIENT_KEY
]
nodes
=
[
n
for
n
,
_
in
result
.
charge_path
]
distance
=
sum
([
map_graph
.
edges
[
u
,
v
][
HAVERSINE_KEY
]
for
u
,
v
in
zip
(
nodes
[:
-
1
],
nodes
[
1
:])])
total_consumption
=
distance
*
consumption
# What has been charged equals what is necessary to reach the goal
assert
round
(
total_consumption
-
mu_s
+
mu_t
)
==
round
(
cs_coefficient
*
charging_time
)
# Charge about 10 min
assert
charg
e_at
[
0
]
<
600
assert
charg
e_at
[
0
]
>
500
assert
charg
ing_time
<
600
assert
charg
ing_time
>
500
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