Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pydtnsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
discus
pydtnsim
Commits
fef5a2db
Commit
fef5a2db
authored
2 years ago
by
ArktikHunter
Browse files
Options
Downloads
Patches
Plain Diff
plotting
parent
9a5603fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!21
pydtn agkmeans and version 1.0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/display.py
+89
-0
89 additions, 0 deletions
examples/display.py
with
89 additions
and
0 deletions
examples/display.py
0 → 100644
+
89
−
0
View file @
fef5a2db
"""
example module for displaying sim results graphically
"""
__all__
=
[
'
display
'
]
__author__
=
"
Hunter McConnell <hunter.mcconnell@usask.ca>
"
import
sys
import
matplotlib.pyplot
as
plt
from
multiprocessing
import
Pool
from
shed
import
Simulation
,
run_simulation
from
pydtnsim
import
Network
,
RandomTraffic
,
Node
,
EpidemicNode
,
CSVTrace
from
pydtnsim.community
import
BubbleKCliqueNode
,
BubbleLouvainNode
from
pydtnsim.community
import
HCBFKCliqueNode
,
HCBFLouvainNode
# run the sim on each taxi dataset, then plot the results together
def
main
():
pool
=
Pool
()
traces
=
[
'
../../processed/taxi10
'
,
'
../../processed/taxi20
'
,
'
../../processed/taxi50
'
,
#'../../processed/taxi100',
]
node_types
=
[
Node
,
# direct delivery
EpidemicNode
,
BubbleKCliqueNode
,
HCBFKCliqueNode
,
BubbleLouvainNode
,
HCBFLouvainNode
,
]
simulations
=
[]
for
trace
in
traces
:
for
node_type
in
node_types
:
sim
=
Simulation
(
trace
=
trace
,
node_type
=
node_type
,
seed
=
None
)
simulations
.
append
(
sim
)
results
=
{}
for
stats
in
pool
.
imap_unordered
(
run_simulation
,
simulations
):
if
stats
[
"
node_type
"
]
not
in
results
:
results
[
stats
[
"
node_type
"
]]
=
{}
results
[
stats
[
"
node_type
"
]][
int
(
traces
.
index
(
stats
[
"
trace
"
]))]
=
stats
print
(
stats
)
# graph the results
figure
,
(
ax1
,
ax2
)
=
plt
.
subplots
(
2
,
sharex
=
True
)
ax1
.
set_ylabel
(
"
Delivery Ratio
"
)
ax2
.
set_ylabel
(
"
Delivery Cost
"
)
x
=
[
10
,
20
,
50
,
#100,
]
for
node
,
stats
in
results
.
items
():
test
=
list
(
zip
(
*
sorted
(
stats
.
items
())))
y1
=
[
stat
[
"
delivery-ratio
"
]
for
stat
in
test
[
1
]]
y2
=
[
stat
[
"
delivery-cost
"
]
for
stat
in
test
[
1
]]
#y3 = [stat["latency"] for stat in test[1]]
ax1
.
plot
(
x
,
y1
,
'
o-
'
,
label
=
node
)
ax2
.
plot
(
x
,
y2
,
'
o-
'
,
label
=
node
)
plt
.
xlabel
(
"
Distance threshhold (m)
"
)
plt
.
legend
()
plt
.
show
()
if
__name__
==
'
__main__
'
:
#sys.exit(main(parse_args(sys.argv[1:])))
sys
.
exit
(
main
())
\ No newline at end of file
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