Skip to content
Snippets Groups Projects
Commit ff96d8e3 authored by Jarrod Pas's avatar Jarrod Pas
Browse files

Adds kclique to simulation

parent 5d02a193
No related branches found
No related tags found
1 merge request!8Adds kclique to simulation
Pipeline #
......@@ -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 [Node, EpidemicNode, BubbleNode, HCBFNode]:
for node_type in node_types:
sim = Simulation(trace=trace, node_type=node_type, seed=seed)
simulations.append(sim)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment