Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
discus
pydtnsim
Commits
ff96d8e3
Commit
ff96d8e3
authored
Aug 18, 2017
by
Jarrod Pas
Browse files
Adds kclique to simulation
parent
5d02a193
Pipeline
#1653
failed with stage
in 1 minute and 27 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
examples/shed.py
View file @
ff96d8e3
...
...
@@ -8,13 +8,42 @@ from collections import namedtuple
from
multiprocessing
import
Pool
from
pydtn
import
Network
,
RandomTraffic
,
Node
,
EpidemicNode
from
pydtn.community
import
BubbleNode
,
HCBFNode
,
LouvainCommunity
from
pydtn.community
import
BubbleNode
,
HCBFNode
from
pydtn.community
import
LouvainCommunity
,
KCliqueCommunity
from
pydtn.shed
import
ShedTrace
Simulation
=
namedtuple
(
'Simulation'
,
[
'trace'
,
'node_type'
,
'seed'
])
class
LouvainNode
(
Node
):
def
__init__
(
self
,
**
options
):
options
[
'community'
]
=
LouvainCommunity
(
options
[
'epoch'
])
super
().
__init__
(
**
options
)
class
LouvainHCBFNode
(
LouvainNode
,
HCBFNode
):
pass
class
LouvainBubbleNode
(
LouvainNode
,
BubbleNode
):
pass
class
KCliqueNode
(
Node
):
def
__init__
(
self
,
**
options
):
options
[
'community'
]
=
KCliqueCommunity
(
options
[
'epoch'
],
options
[
'k'
])
super
().
__init__
(
**
options
)
class
KCliqueHCBFNode
(
KCliqueNode
,
HCBFNode
):
pass
class
KCliqueBubbleNode
(
KCliqueNode
,
BubbleNode
):
pass
def
run_simulation
(
simulation
):
"""Run a simulation."""
seed
=
simulation
.
seed
...
...
@@ -26,7 +55,8 @@ def run_simulation(simulation):
node_type
=
simulation
.
node_type
node_options
=
{
'tick_rate'
:
5
*
60
,
# 5 mins
'community'
:
LouvainCommunity
(
epoch
),
'epoch'
:
epoch
,
'k'
:
3
,
}
nodes
=
{
node_id
:
simulation
.
node_type
(
**
node_options
)
...
...
@@ -36,7 +66,7 @@ def run_simulation(simulation):
traffic_options
=
{
'seed'
:
seed
,
'start'
:
epoch
,
'step'
:
30
*
60
,
# 1 packet every
30
mins
'step'
:
1
*
60
,
# 1 packet every
1
mins
}
traffic
=
RandomTraffic
(
nodes
,
**
traffic_options
)
...
...
@@ -59,9 +89,17 @@ def main(args):
trace
=
args
[
'shed'
]
pool
=
Pool
()
simulations
=
[]
node_types
=
[
Node
,
EpidemicNode
,
KCliqueBubbleNode
,
KCliqueHCBFNode
,
LouvainBubbleNode
,
LouvainHCBFNode
,
]
for
seed
in
args
[
'seeds'
]:
for
node_type
in
[
N
ode
,
EpidemicNode
,
BubbleNode
,
HCBFNode
]
:
for
node_type
in
n
ode
_types
:
sim
=
Simulation
(
trace
=
trace
,
node_type
=
node_type
,
seed
=
seed
)
simulations
.
append
(
sim
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment