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
d3bd7f63
Commit
d3bd7f63
authored
4 years ago
by
markn92
Browse files
Options
Downloads
Patches
Plain Diff
get the bug
parent
5cb4d557
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/no_test_debug.py
+41
-20
41 additions, 20 deletions
tests/osm/no_test_debug.py
with
41 additions
and
20 deletions
tests/osm/no_test_debug.py
+
41
−
20
View file @
d3bd7f63
import
os
import
json
import
datetime
import
pickle
import
pandas
as
pd
from
time
import
perf_counter
import
pytest
from
evrouting.osm.imports
import
OSMGraph
...
...
@@ -13,12 +15,19 @@ STATIC_DIR = os.path.join(os.path.dirname(__file__), 'static')
@pytest.fixture
def
large_graph
():
with
open
(
os
.
path
.
join
(
STATIC_DIR
,
'
oberpfalz-latest
.pck
'
),
'
rb
'
)
as
f
:
with
open
(
os
.
path
.
join
(
STATIC_DIR
,
'
medium_nurnberg
.pck
'
),
'
rb
'
)
as
f
:
G
:
OSMGraph
=
pickle
.
load
(
f
)
G
.
rebuild_rtree
()
return
G
@pytest.fixture
def
tasks
():
path
=
os
.
path
.
join
(
STATIC_DIR
,
'
classic.csv
'
)
df
=
pd
.
read_csv
(
path
,
dtype
=
{
'
start_node
'
:
str
,
'
target_node
'
:
str
})
return
[(
row
[
'
start_node
'
],
row
[
'
target_node
'
])
for
_
,
row
in
df
.
iterrows
()]
@pytest.fixture
def
charging_stations
():
with
open
(
os
.
path
.
join
(
STATIC_DIR
,
'
charging_stations.json
'
),
'
r
'
)
as
f
:
...
...
@@ -26,23 +35,35 @@ def charging_stations():
return
charging_stations
def
test_debug
(
large_graph
):
def
test_debug
(
large_graph
,
charging_stations
,
tasks
):
"""
Full tank is enough to get there. Must be equal to shortest path.
"""
G
=
large_graph
_s
=
'
2151728389
'
_t
=
'
4383892857
'
consumption
=
1000
*
0.1
c
=
consumption_function_time_factory
(
consumption
)
result
=
charge
.
routing
.
shortest_path
(
G
=
G
,
charging_stations
=
G
.
charging_stations
,
s
=
_s
,
t
=
_t
,
initial_soc
=
300000
,
# > cost_path
final_soc
=
0
,
capacity
=
300000
,
c
=
c
)
assert
result
.
trip_time
is
not
None
G
.
insert_charging_stations
(
charging_stations
)
c
=
consumption_function_time_factory
(
0.5
)
mu_s
=
40000
mu_t
=
0
capacity
=
40000
total_tasks
=
len
(
tasks
)
for
i
,
(
s
,
t
)
in
enumerate
(
tasks
):
now
=
datetime
.
datetime
.
now
().
strftime
(
"
%H:%M:%S
"
)
print
(
f
'
{
now
}
:
{
i
}
/
{
total_tasks
}
(
{
(
i
/
total_tasks
)
*
100
:
.
2
f
}
%)
'
)
nodes_before
=
set
(
G
.
nodes
)
edges_before
=
set
(
G
.
edges
)
start
=
perf_counter
()
charge
.
routing
.
shortest_path
(
G
=
G
,
charging_stations
=
G
.
charging_stations
,
s
=
s
,
t
=
t
,
initial_soc
=
mu_s
,
final_soc
=
mu_t
,
capacity
=
capacity
,
c
=
c
)
runtime
=
perf_counter
()
-
start
assert
nodes_before
^
set
(
G
.
nodes
)
==
set
()
assert
edges_before
^
set
(
G
.
edges
)
==
set
()
assert
runtime
<
100
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