本文整理汇总了Python中simulation.Simulation.slottedAloha方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.slottedAloha方法的具体用法?Python Simulation.slottedAloha怎么用?Python Simulation.slottedAloha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulation.Simulation
的用法示例。
在下文中一共展示了Simulation.slottedAloha方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Simulation
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import slottedAloha [as 别名]
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)
print "^" * 125
print "Slotted Aloha - Selfish Node Throughput for 2 Nodes (1/1): ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.slottedAlohaSelfish, SETTINGS.SIMULATION_LENGTH, 1, 1))
print "Slotted Aloha - Selfish Node Throughput for 3 Nodes (2/1): ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.slottedAlohaSelfish, SETTINGS.SIMULATION_LENGTH, 2, 1))
print "Slotted Aloha - Selfish Node Throughput for 3 Nodes (1/2): ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.slottedAlohaSelfish, SETTINGS.SIMULATION_LENGTH, 1, 2))
print "Slotted Aloha - Selfish Node Throughput for 4 Nodes (3/1): ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.slottedAlohaSelfish, SETTINGS.SIMULATION_LENGTH, 3, 1))
print "Slotted Aloha - Selfish Node Throughput for 4 Nodes (2/2): ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.slottedAlohaSelfish, SETTINGS.SIMULATION_LENGTH, 2, 2))
print "Slotted Aloha - Selfish Node Throughput for 4 Nodes (1/3): ", np.mean(sim.repeatSim(SETTINGS.SIMULATIONS, sim.slottedAlohaSelfish, SETTINGS.SIMULATION_LENGTH, 1, 3))