Commit 628250eb authored by Jarrod Pas's avatar Jarrod Pas
Browse files

Update shed example

parent 58089657
...@@ -9,7 +9,7 @@ from multiprocessing import Pool ...@@ -9,7 +9,7 @@ from multiprocessing import Pool
from pydtn import Network, RandomTraffic, Node, EpidemicNode from pydtn import Network, RandomTraffic, Node, EpidemicNode
from pydtn.community import BubbleNode, HCBFNode, LouvainCommunity from pydtn.community import BubbleNode, HCBFNode, LouvainCommunity
import pydtn.shed as shed from pydtn.shed import ShedTrace
Simulation = namedtuple('Simulation', ['trace', 'node_type', 'seed']) Simulation = namedtuple('Simulation', ['trace', 'node_type', 'seed'])
...@@ -19,8 +19,7 @@ def run_simulation(simulation): ...@@ -19,8 +19,7 @@ def run_simulation(simulation):
"""Run a simulation.""" """Run a simulation."""
seed = simulation.seed seed = simulation.seed
trace_metadata = shed.read_meta_file(simulation.trace) trace = ShedTrace(simulation.trace)
trace = shed.shed_trace(simulation.trace)
epoch = 7*24*60*60 # 7 days epoch = 7*24*60*60 # 7 days
...@@ -31,13 +30,13 @@ def run_simulation(simulation): ...@@ -31,13 +30,13 @@ def run_simulation(simulation):
} }
nodes = { nodes = {
node_id: simulation.node_type(**node_options) node_id: simulation.node_type(**node_options)
for node_id in range(trace_metadata['nodes']) for node_id in range(trace.nodes)
} }
traffic_options = { traffic_options = {
'seed': seed, 'seed': seed,
'start': epoch, 'start': epoch,
'speed': 30 * 60, # 1 packet every 30 mins 'step': 30 * 60, # 1 packet every 30 mins
} }
traffic = RandomTraffic(nodes, **traffic_options) traffic = RandomTraffic(nodes, **traffic_options)
...@@ -45,7 +44,7 @@ def run_simulation(simulation): ...@@ -45,7 +44,7 @@ def run_simulation(simulation):
network.run() network.run()
stats = { stats = {
'trace': simulation.trace, 'trace': trace.path,
'node_type': node_type.__name__, 'node_type': node_type.__name__,
'seed': seed, 'seed': seed,
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment