def test_add_edge_lengths(self): g1 = qt.generate_pagerank_graph(10) g2 = qt.add_edge_lengths(g1) edge_props = set() for key in g2.edge_properties(): edge_props.add(key) self.assertTrue('edge_length' in edge_props)
def test_QueueNetwork_simulate(self): g = qt.generate_pagerank_graph(50) qn = qt.QueueNetwork(g) qn.max_agents = 2000 qn.initialize(50) t0 = np.random.uniform(30, 50) qn.max_agents = 2000 qn.simulate(t=t0) self.assertGreater(qn.current_time, t0)
import queueing_tool as qt import matplotlib.animation as manimation from matplotlib import * g = qt.generate_pagerank_graph(4, seed=13) net = qt.QueueNetwork(g, seed=13) net.initialize() net.animate(figsize=(4, 4)) kwargs = { 'filename': 'test.mp4', 'frames': 300, 'fps': 30, 'writer': 'mencoder', 'figsize': (4, 4), 'vertex_size': 15 } """ This method calls FuncAnimation and optionally matplotlib.animation.FuncAnimation.save(). Any keyword that can be passed to these functions are passed via kwargs. """ net.animate(**kwargs)
def setUpClass(cls): cls.g = qt.generate_pagerank_graph(200) cls.qn = qt.QueueNetwork(cls.g) cls.qn.g.draw_graph = mock.MagicMock() cls.qn.max_agents = 2000 cls.qn.initialize(50)
def test_QueueNetwork_init_error(self): g = qt.generate_pagerank_graph(7) with self.assertRaises(TypeError): qt.QueueNetwork(g, blocking=2)
net.simulate(50000) # set 50000 events net.num_events print("Number of events: ", net.num_events) def time(): t0 = net.current_time net.simulate(t=75) t1 = net.current_time result = t1 - t0 print("current time: ", t0) print("current time: ", t1) print("Simulation Time: ", result) """ conclusion: there are two kind of simulation method. Event / Time """ if __name__ == "__main__": g = qt.generate_pagerank_graph(100, seed=50) # 100 nodes net = qt.QueueNetwork(g, seed=50) net.initialize(2) event() time()