當前位置: 首頁>>代碼示例>>Python>>正文


Python System.infections[7]方法代碼示例

本文整理匯總了Python中system.System.infections[7]方法的典型用法代碼示例。如果您正苦於以下問題:Python System.infections[7]方法的具體用法?Python System.infections[7]怎麽用?Python System.infections[7]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在system.System的用法示例。


在下文中一共展示了System.infections[7]方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: unitTest

# 需要導入模塊: from system import System [as 別名]
# 或者: from system.System import infections[7] [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)
開發者ID:nickjmeyer,項目名稱:stdmMf,代碼行數:43,代碼來源:agents.py


注:本文中的system.System.infections[7]方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。