本文整理匯總了Python中system.System.infections[4]方法的典型用法代碼示例。如果您正苦於以下問題:Python System.infections[4]方法的具體用法?Python System.infections[4]怎麽用?Python System.infections[4]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類system.System
的用法示例。
在下文中一共展示了System.infections[4]方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: unitTest
# 需要導入模塊: from system import System [as 別名]
# 或者: from system.System import infections[4] [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)