本文整理汇总了Python中simulation.Simulation.pureAloha方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.pureAloha方法的具体用法?Python Simulation.pureAloha怎么用?Python Simulation.pureAloha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulation.Simulation
的用法示例。
在下文中一共展示了Simulation.pureAloha方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Simulation
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import pureAloha [as 别名]
#!/bin/python
import numpy as np
from nodes import PureNode
from nodes import SlottedNode
from simulation import Simulation
import SETTINGS
SETTINGS.init()
sim = Simulation()
print "Throughput numbers are computed using " + str(SETTINGS.SIMULATIONS) + " simulations and " + str(SETTINGS.SIMULATION_LENGTH) + " ticks with frame size of " + str(SETTINGS.FRAME_SIZE) + " ticks"
print "Probabilities of transmit: Pure Node(" + str(SETTINGS.PURE_PROBABILITY) + ") Slotted(" + str(SETTINGS.SLOTTED_PROBABILITY) + ")\n"
sim.pureAloha(40, 2, True)
print "^" * 125
print "Pure Aloha Throughput for 2 Nodes: ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.pureAloha, SETTINGS.SIMULATION_LENGTH, 2))
print "Pure Aloha Throughput for 3 Nodes: ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.pureAloha, SETTINGS.SIMULATION_LENGTH, 3))
print "Pure Aloha Throughput for 4 Nodes: ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.pureAloha, SETTINGS.SIMULATION_LENGTH, 4))
print "Pure Aloha Throughput for 8 Nodes: ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.pureAloha, SETTINGS.SIMULATION_LENGTH, 8))
print "^" * 125 + "\n"
sim.slottedAloha(40, 2, True)
print "^" * 125
print "Slotted Aloha Throughput for 2 Nodes: ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.slottedAloha, SETTINGS.SIMULATION_LENGTH, 2))
print "Slotted Aloha Throughput for 3 Nodes: ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.slottedAloha, SETTINGS.SIMULATION_LENGTH, 3))
print "Slotted Aloha Throughput for 4 Nodes: ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.slottedAloha, SETTINGS.SIMULATION_LENGTH, 4))
print "Slotted Aloha Throughput for 8 Nodes: ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.slottedAloha, SETTINGS.SIMULATION_LENGTH, 8))
print "^" * 125 + "\n"
sim.slottedAlohaSelfish(40, 1, 1, True)