当前位置: 首页>>代码示例>>Python>>正文


Python Model.fromFile方法代码示例

本文整理汇总了Python中Model.Model.fromFile方法的典型用法代码示例。如果您正苦于以下问题:Python Model.fromFile方法的具体用法?Python Model.fromFile怎么用?Python Model.fromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model.Model的用法示例。


在下文中一共展示了Model.fromFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: len

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import fromFile [as 别名]
#!/usr/bin/env python3
# should be locate in main directory
import sys

if len(sys.argv) != 3:
	print("{} <model-file> <events-file>".format(sys.argv[0]))
	sys.exit(1)

from matplotlib import pyplot
pyplot.rcParams["figure.figsize"] = [5.75, 2.5]

from Model import Model
from Events import Events

model, events = Model.fromFile(sys.argv[1]), Events.fromFile(sys.argv[2])

count = dict((p, 0) for p in model.packets)
trace = dict((p, []) for p in model.packets)
cumTrace = []

events.next()
while events.hasNext():
	event = events.next()
	time, packet = event.time, event.packet
	count[packet] += 1
	tcount = model.rate * model.probability(packet) * time
	trace[packet].append((time, count[packet], tcount, count[packet] / tcount))

	cumTrace.append((time, sum(count[p] for p in model.packets) / model.rate / time))

lr, = pyplot.plot(list(map(lambda e: e[0], cumTrace)), [1] * len(cumTrace))
开发者ID:rslawik,项目名称:mgr-simulation,代码行数:33,代码来源:verify_generate.py

示例2: test_createModelFromFile

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import fromFile [as 别名]
	def test_createModelFromFile(self):
		model = Model.fromFile('tests/example/model.in')
		self.assertModelEqual(model, 5, {3.0: 0.33, 5.0: 0.17, 7.0: 0.5}, 1.5)	
开发者ID:rslawik,项目名称:mgr-simulation,代码行数:5,代码来源:test_Model.py

示例3: test_createModelFromFile_noFile

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import fromFile [as 别名]
	def test_createModelFromFile_noFile(self):
		with self.assertRaises(FileNotFoundError):
			model = Model.fromFile('tests/example/modelXXX.in')
开发者ID:rslawik,项目名称:mgr-simulation,代码行数:5,代码来源:test_Model.py

示例4: WaitEvent

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import fromFile [as 别名]
		if error:
			events.schedule(ErrorEvent(time + error) if error >= 0 else WaitEvent())

	while events.hasNext():
		event = events.next()
		time = event.time
		log(event)

		algorithm.notify(event)
		adversary.notify(event)

		if events.hasNextNow(time): continue

		if not algorithm.sending:
			packet = schedule(algorithm)
			packet = packet / speedup if packet else None
			error = adversary.algorithmSchedules(packet)
			scheduleError(time, error)

		if not adversary.sending:
			advpacket = schedule(adversary)
			error = adversary.adversarySchedules(advpacket)
			scheduleError(time, error)

model = Model.fromFile(sys.argv[4])
algorithm = getattr(Algorithm, sys.argv[1])(model)
adversary = getattr(Adversary, sys.argv[2])(model)
events = Events.fromFile(sys.argv[3])

play(algorithm, adversary, events, model.speedup)
开发者ID:rslawik,项目名称:mgr-simulation,代码行数:32,代码来源:simulate.py


注:本文中的Model.Model.fromFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。