本文整理汇总了Python中system.System.infections[2]方法的典型用法代码示例。如果您正苦于以下问题:Python System.infections[2]方法的具体用法?Python System.infections[2]怎么用?Python System.infections[2]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类system.System
的用法示例。
在下文中一共展示了System.infections[2]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unitTest
# 需要导入模块: from system import System [as 别名]
# 或者: from system.System import infections[2] [as 别名]
def unitTest(cls):
print "Testing QAgent"
from system import System
from networks import genGridNetwork
from model import PJ
s = System(genGridNetwork((4,3)),PJ())
s.cleanse()
s.infections[2] = True
s.infections[4] = True
s.infections[7] = True
numTrt = Agent.numTrt(s)
numNodes = s.network.numNodes
assert numNodes == 12, ("numNodes is not 12")
assert numTrt == 3, ("numTrt is not 3")
maxInfInd = 1 << numNodes
maxTrtInd = Agent.numValidTrt(numNodes,numTrt)
q = [[0]*maxTrtInd for i in range(maxInfInd)]
for i in range(maxInfInd):
for t in range(maxTrtInd):
q[i][t] = t
trtNodes = [9,10,11]
a = cls.fromQ(q)
a.applyTrt(s)
if s.nTrt > len(trtNodes):
raise ValueError("QAgent gave too many treatments ")
elif s.nTrt < len(trtNodes):
raise ValueError("QAgent gave too few treatments")
else:
for i in trtNodes:
if not s.treatments[i]:
raise ValueError("QAgent did not treat node " + i)