本文整理汇总了Python中pypdevs.DEVS.CoupledDEVS.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python CoupledDEVS.__init__方法的具体用法?Python CoupledDEVS.__init__怎么用?Python CoupledDEVS.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypdevs.DEVS.CoupledDEVS
的用法示例。
在下文中一共展示了CoupledDEVS.__init__方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pypdevs.DEVS import CoupledDEVS [as 别名]
# 或者: from pypdevs.DEVS.CoupledDEVS import __init__ [as 别名]
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)
示例2: __init__
# 需要导入模块: from pypdevs.DEVS import CoupledDEVS [as 别名]
# 或者: from pypdevs.DEVS.CoupledDEVS import __init__ [as 别名]
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)
示例3: __init__
# 需要导入模块: from pypdevs.DEVS import CoupledDEVS [as 别名]
# 或者: from pypdevs.DEVS.CoupledDEVS import __init__ [as 别名]
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)
示例4: __init__
# 需要导入模块: from pypdevs.DEVS import CoupledDEVS [as 别名]
# 或者: from pypdevs.DEVS.CoupledDEVS import __init__ [as 别名]
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
示例5: __init__
# 需要导入模块: from pypdevs.DEVS import CoupledDEVS [as 别名]
# 或者: from pypdevs.DEVS.CoupledDEVS import __init__ [as 别名]
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])