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


Python DEVS.CoupledDEVS類代碼示例

本文整理匯總了Python中pypdevs.DEVS.CoupledDEVS的典型用法代碼示例。如果您正苦於以下問題:Python CoupledDEVS類的具體用法?Python CoupledDEVS怎麽用?Python CoupledDEVS使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: __init__

    def __init__(self, nodes, atomicsPerNode, iterations, percentageremotes):
        CoupledDEVS.__init__(self, "PHOLD")
        self.processors = []
        have = 0
        destinations = []
        cntr = 0
        totalAtomics = nodes * atomicsPerNode
        procs = []
        for node in range(nodes):
            procs.append([])
            for i in range(atomicsPerNode):
                procs[-1].append(atomicsPerNode*node+i)
        cntr = 0
        global distributed
        for e, i in enumerate(procs):
            allnoi = []
            for e2, j in enumerate(procs):
                if e2 != e:
                    allnoi.extend(j)
            for j in i:
                inoj = list(i)
                inoj.remove(j)
                self.processors.append(self.addSubModel(HeavyPHOLDProcessor("Processor_%d" % cntr, iterations, totalAtomics, cntr, inoj, allnoi, percentageremotes), e if distributed else 0))
                cntr += 1

        # All nodes created, now create all connections
        for i in range(len(self.processors)):
            for j in range(len(self.processors)):
                if i == j:
                    continue
                self.connectPorts(self.processors[i].OPorts[j], self.processors[j].inport)
開發者ID:kdheepak,項目名稱:pypdevs,代碼行數:31,代碼來源:PHOLD.py

示例2: __init__

 def __init__(self):
     CoupledDEVS.__init__(self, "ChainPeekPoke")
     self.generator = self.addSubModel(CoupledGenerator(1.0))
     self.processor1 = self.addSubModel(CoupledProcessor(0.66, 2))
     self.processor2 = self.addSubModel(CoupledProcessor(0.30, 3))
     self.connectPorts(self.generator.outport, self.processor1.inport)
     self.connectPorts(self.processor1.outport, self.processor2.inport)
開發者ID:kdheepak,項目名稱:pypdevs,代碼行數:7,代碼來源:models.py

示例3: __init__

 def __init__(self):
     CoupledDEVS.__init__(self, "DQueue")
     self.generator = self.addSubModel(Generator())
     self.queue1 = self.addSubModel(Queue())
     self.queue2 = self.addSubModel(Queue())
     self.connectPorts(self.generator.outport, self.queue1.inport)
     self.connectPorts(self.generator.outport, self.queue2.inport)
開發者ID:kdheepak,項目名稱:pypdevs,代碼行數:7,代碼來源:queue_example.py

示例4: __init__

 def __init__(self, width):
         CoupledDEVS.__init__(self, "Queue")
         self.generator = self.addSubModel(Generator())
         prev = self.generator
         seeds = [i * 1000 for i in range(width)]
         for i in range(width):
             m = self.addSubModel(Processor("Processor%i" % i, seeds[i]))
             self.connectPorts(prev.send_event1, m.recv_event1)
             prev = m
開發者ID:kdheepak,項目名稱:pypdevs,代碼行數:9,代碼來源:QueueModel.py

示例5: __init__

    def __init__(self, x_max, y_max):
        CoupledDEVS.__init__(self, "FireSpread")

        self.cells = []
        try:
            from mpi4py import MPI
            nodes = MPI.COMM_WORLD.Get_size()
        except ImportError:
            nodes = 1
        node = 0
        totalCount = x_max * y_max
        counter = 0
        for x in range(x_max):
            row = []
            for y in range(y_max):
                if nodes == 1:
                    node = 0
                elif x <= x_max/2 and y < y_max/2:
                    node = 0
                elif x <= x_max/2 and y > y_max/2:
                    node = 1
                elif x > x_max/2 and y < y_max/2:
                    node = 2
                elif x > x_max/2 and y > y_max/2:
                    node = 3
                row.append(self.addSubModel(Cell(x, y, x_max, y_max), node))
            self.cells.append(row)
            counter += 1

        # Everything is now constructed, so connect the ports now
        self.generator = self.addSubModel(Generator(RADIUS))
        self.putGenerator(x_max/2, y_max/2)

        for x in range(x_max):
            for y in range(y_max):
                if x != 0:
                    self.connectPorts(self.cells[x][y].outport, self.cells[x-1][y].inports[2])
                if y != y_max - 1:
                    self.connectPorts(self.cells[x][y].outport, self.cells[x][y+1].inports[1])
                if x != x_max - 1:
                    self.connectPorts(self.cells[x][y].outport, self.cells[x+1][y].inports[3])
                if y != 0:
                    self.connectPorts(self.cells[x][y].outport, self.cells[x][y-1].inports[0])
開發者ID:kdheepak,項目名稱:pypdevs,代碼行數:43,代碼來源:model.py


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