def __init__(self): CoupledDEVS.__init__(self, "Binary") self.generator = self.addSubModel(CoupledGenerator(1.0, True)) self.processor1 = self.addSubModel(CoupledProcessor(0.6, 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)
def __init__(self): CoupledDEVS.__init__(self, "MultiNested") self.generator = self.addSubModel(Generator("Generator", 1)) self.processor1 = self.addSubModel(NestedProcessor("NProcessor1"), 1) self.processor2 = self.addSubModel(NestedProcessor("NProcessor2"), 2) self.connectPorts(self.generator.outport, self.processor1.inport) self.connectPorts(self.processor1.outport, self.processor2.inport)
def __init__(self, ta): CoupledDEVS.__init__(self, "DualChain") self.generator = self.addSubModel(CoupledGenerator(1.0), 1) self.processor1 = self.addSubModel(CoupledProcessor(ta, 2), 2) self.processor2 = self.addSubModel(CoupledProcessor(0.30, 3)) self.connectPorts(self.generator.outport, self.processor1.inport) self.connectPorts(self.generator.outport, self.processor2.inport)
def __init__(self): CoupledDEVS.__init__(self, "OptimizableChain") self.generator = self.addSubModel(CoupledGenerator(1.0)) self.processor1 = self.addSubModel(CoupledProcessor(0.66, 2), 1) self.processor2 = self.addSubModel(CoupledProcessor(0.30, 3), 2) self.connectPorts(self.generator.outport, self.processor1.inport) self.connectPorts(self.processor1.outport, self.processor2.inport)
def __init__(self): CoupledDEVS.__init__(self, "Local") self.generator = self.addSubModel(Generator("Generator", 1)) self.processor1 = self.addSubModel(CoupledProcessor(1, 2)) self.processor2 = self.addSubModel(CoupledProcessor(1, 3)) self.connectPorts(self.generator.outport, self.processor1.inport) self.connectPorts(self.processor1.outport, self.processor2.inport)
def __init__(self): CoupledDEVS.__init__(self, "Root") self.generator = self.addSubModel(CoupledGenerator(1.0)) self.processor1 = self.addSubModel(RemoteDCProcessor(), 1) self.processor2 = self.addSubModel(CoupledProcessor(0.30, 3)) self.connectPorts(self.generator.outport, self.processor1.inport) self.connectPorts(self.processor1.outport, self.processor2.inport)
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)
def __init__(self): CoupledDEVS.__init__(self, "RemoteDCProcessor") mod = self.addSubModel(CoupledProcessor(1, 1), 2) self.inport = self.addInPort("inport") self.outport = self.addOutPort("outport") self.connectPorts(self.inport, mod.inport) self.connectPorts(mod.outport, self.outport)
def __init__(self): CoupledDEVS.__init__(self, "Layer2") self.lower = self.addSubModel(DoubleLayer1()) self.inport1 = self.addInPort("inport1") self.inport2 = self.addInPort("inport2") self.connectPorts(self.inport1, self.lower.inport) self.connectPorts(self.inport2, self.lower.inport)
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)
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)
def __init__(self): CoupledDEVS.__init__(self, "Root") self.submodel = self.addSubModel(GeneratorDS()) self.submodel2 = self.addSubModel(Processor()) self.submodel3 = self.addSubModel(Processor()) self.connectPorts(self.submodel.outport, self.submodel2.inport) self.connectPorts(self.submodel2.outport, self.submodel3.inport) self.connectPorts(self.submodel.outport, self.submodel3.inport)
def __init__(self): CoupledDEVS.__init__(self, "ROOT") self.gen = self.addSubModel(Generator()) self.proc1 = self.addSubModel(ZCoupledProcessor(1), 1) self.proc2 = self.addSubModel(ZCoupledProcessor(2), 2) self.connectPorts(self.gen.outport, self.proc1.inport) self.connectPorts(self.gen.outport, self.proc2.inport, trans2)
def __init__(self, t_gen_event1 = 1): CoupledDEVS.__init__(self, "CoupledGenerator") self.generator = self.addSubModel(GeneratorNPP("Generator", t_gen_event1)) self.inport = self.addInPort("inport") self.outport = self.addOutPort("outport") self.connectPorts(self.inport, self.generator.inport) self.connectPorts(self.generator.outport, self.outport)
def __init__(self, ta): CoupledDEVS.__init__(self, "DualDepthProcessor") self.inport = self.addInPort("inport") self.outport = self.addOutPort("outport") self.processor1 = self.addSubModel(CoupledProcessor(ta, 1), 2) self.processor2 = self.addSubModel(CoupledProcessor(ta, 2)) self.connectPorts(self.inport, self.processor1.inport) self.connectPorts(self.processor1.outport, self.processor2.inport) self.connectPorts(self.processor2.outport, self.outport)
def __init__(self, iterations): CoupledDEVS.__init__(self, "HugeOptimizableChain") self.generator = self.addSubModel(CoupledGenerator(1.0)) self.processor0 = self.addSubModel(CoupledHeavyProcessor(0.77, 10, iterations)) self.processor1 = self.addSubModel(CoupledHeavyProcessor(0.66, 10, iterations)) self.processor2 = self.addSubModel(CoupledHeavyProcessor(0.30, 10, iterations)) self.connectPorts(self.generator.outport, self.processor0.inport) self.connectPorts(self.processor0.outport, self.processor1.inport) self.connectPorts(self.processor0.outport, self.processor2.inport)
def __init__(self): CoupledDEVS.__init__(self, "Coupled") self.generator = self.addSubModel(Generator()) self.processor1 = self.addSubModel(RandomProcessor(1)) self.processor2 = self.addSubModel(RandomProcessor(2)) self.processor3 = self.addSubModel(RandomProcessor(3)) self.connectPorts(self.generator.outport, self.processor1.inport) self.connectPorts(self.processor1.outport, self.processor2.inport) self.connectPorts(self.processor2.outport, self.processor3.inport)
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
def __init__(self): CoupledDEVS.__init__(self, "Boundary") self.generator = self.addSubModel(CoupledGenerator(1.0), 1) self.processor1 = self.addSubModel(CoupledProcessor(0.60, 2), 2) self.processor2 = self.addSubModel(CoupledProcessor(0.30, 4), 3) self.processor3 = self.addSubModel(CoupledProcessor(0.30, 3)) self.connectPorts(self.generator.outport, self.processor1.inport) self.connectPorts(self.processor1.outport, self.processor2.inport) self.connectPorts(self.processor1.outport, self.processor3.inport) self.connectPorts(self.processor2.outport, self.processor3.inport)
def __init__(self, t_event1_P1): CoupledDEVS.__init__(self, "CoupledProcessorMP") self.inport = self.addInPort("inport") p1 = self.addSubModel(Processor("Processor1", t_event1_P1)) p2 = self.addSubModel(Processor("Processor2", t_event1_P1)) p3 = self.addSubModel(Processor("Processor3", t_event1_P1)) p4 = self.addSubModel(Processor("Processor4", t_event1_P1)) self.connectPorts(self.inport, p1.inport) self.connectPorts(self.inport, p3.inport) self.connectPorts(p1.outport, p2.inport) self.connectPorts(p3.outport, p4.inport)
def __init__(self, t_event1_P1, levels): CoupledDEVS.__init__(self, "CoupledProcessor_" + str(levels)) self.inport = self.addInPort("inport") self.outport = self.addOutPort("outport") self.coupled = [] for i in range(levels): self.coupled.append(self.addSubModel(Processor("Processor" + str(i), t_event1_P1))) for i in range(levels-1): self.connectPorts(self.coupled[i].outport, self.coupled[i+1].inport) self.connectPorts(self.inport, self.coupled[0].inport) self.connectPorts(self.coupled[-1].outport, self.outport)
def __init__(self): CoupledDEVS.__init__(self, "MultipleInputs") self.generator = self.addSubModel(Generator(1.0)) self.processors1 = [] for i in xrange(5): self.processors1.append(self.addSubModel(Processor("1-" + str(i), 0.3))) self.connectPorts(self.generator.outport, self.processors1[-1].inport) self.processors2 = [] for i in xrange(2): self.processors2.append(self.addSubModel(Processor("2-" + str(i), 0.3))) for s in self.processors1: self.connectPorts(s.outport, self.processors2[-1].inport)
def __init__(self): CoupledDEVS.__init__(self, "Chain") self.generator = self.addSubModel(CoupledGenerator(1.0), 0) self.processor1 = self.addSubModel(CoupledProcessor(0.66, 2), 1) self.processor2 = self.addSubModel(CoupledProcessor(0.66, 3), 2) self.processor3 = self.addSubModel(CoupledProcessor(0.66, 4), 1) self.processor4 = self.addSubModel(CoupledProcessor(0.66, 5), 0) self.processor5 = self.addSubModel(CoupledProcessor(0.30, 6), 2) self.connectPorts(self.generator.outport, self.processor1.inport) self.connectPorts(self.processor1.outport, self.processor2.inport) self.connectPorts(self.processor2.outport, self.processor3.inport) self.connectPorts(self.processor3.outport, self.processor4.inport) self.connectPorts(self.processor4.outport, self.processor5.inport)
def __init__(self): CoupledDEVS.__init__(self, "Coupled") self.inport1 = self.addInPort("inport1") self.inport2 = self.addInPort("inport2") self.outport = self.addOutPort("outport") self.proc1 = self.addSubModel(ProcessorClassic1()) self.proc2 = self.addSubModel(ProcessorClassic1()) self.connectPorts(self.inport1, self.proc1.inport) self.connectPorts(self.inport2, self.proc2.inport) self.connectPorts(self.proc1.outport, self.outport) self.connectPorts(self.proc2.outport, self.outport)
def __init__(self, num): CoupledDEVS.__init__(self, "CoupledProcessor_" + str(num)) self.inport = self.addInPort("inport") self.outport = self.addOutPort("outport") self.coupled = [] levels = 4 for i in range(levels): self.coupled.append(self.addSubModel(Processor("Processor" + str(i), 1.0))) for i in range(levels-1): self.connectPorts(self.coupled[i].outport, self.coupled[i+1].inport, trans1) self.connectPorts(self.inport, self.coupled[0].inport) self.connectPorts(self.coupled[-1].outport, self.outport)
def __init__(self, t_event1_P1, levels, iterations, name = None): if name == None: name = "CoupledHeavyProcessor_" + str(levels) CoupledDEVS.__init__(self, name) self.inport = self.addInPort("inport") self.outport = self.addOutPort("outport") self.coupled = [] for i in range(levels): self.coupled.append(self.addSubModel(HeavyProcessor("Processor" + str(i), t_event1_P1, iterations))) for i in range(levels-1): self.connectPorts(self.coupled[i].outport, self.coupled[i+1].inport) self.connectPorts(self.inport, self.coupled[0].inport) self.connectPorts(self.coupled[-1].outport, self.outport)
def __init__(self): CoupledDEVS.__init__(self, "Root") self.model1 = self.addSubModel(GeneratorClassic()) self.model2 = self.addSubModel(ProcessorCoupledClassic()) self.model3 = self.addSubModel(ProcessorClassic2()) self.model4 = self.addSubModel(ProcessorClassic1()) self.model5 = self.addSubModel(ProcessorClassicO2()) self.connectPorts(self.model1.outport, self.model2.inport1) self.connectPorts(self.model1.outport, self.model2.inport2) self.connectPorts(self.model2.outport, self.model3.inport1) self.connectPorts(self.model2.outport, self.model3.inport2) self.connectPorts(self.model3.outport, self.model5.inport) self.connectPorts(self.model2.outport, self.model4.inport) self.connectPorts(self.model4.outport, self.model5.inport)
def __init__(self, nodes, totalAtomics, iterations): CoupledDEVS.__init__(self, "AutoDistChain") self.generator = self.addSubModel(CoupledGenerator(1.0)) self.processors = [] have = 0 ta = 0.66 for i in range(nodes): shouldhave = (float(i+1) / nodes) * totalAtomics num = int(shouldhave - have) have += num if i == 0: self.processors.append(self.addSubModel(CoupledHeavyProcessor(ta, num, iterations, "HeavyProcessor_" + str(i)))) else: self.processors.append(self.addSubModel(CoupledHeavyProcessor(ta, num, iterations, "HeavyProcessor_" + str(i)), i)) self.connectPorts(self.generator.outport, self.processors[0].inport) for i in range(len(self.processors)-1): self.connectPorts(self.processors[i].outport, self.processors[i+1].inport)
def __init__(self, it, namecounter): CoupledDEVS.__init__(self, "CoupledProcessor_%s_%s" % (it, namecounter)) self.inport = self.addInPort("inport") self.outport = self.addOutPort("outport") if it != 0: self.subproc = self.addSubModel(ClassicCoupledProcessor(it-1, 0)) else: self.subproc = self.addSubModel(ClassicProcessor(0)) self.subproc2 = self.addSubModel(ClassicProcessor(1)) if it != 0: self.subproc3 = self.addSubModel(ClassicCoupledProcessor(it-1, 2)) else: self.subproc3 = self.addSubModel(ClassicProcessor(2)) self.connectPorts(self.inport, self.subproc.inport) self.connectPorts(self.subproc.outport, self.subproc2.inport) self.connectPorts(self.subproc2.outport, self.subproc3.inport) self.connectPorts(self.subproc3.outport, self.outport)
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])
def __init__(self, it, namecounter): CoupledDEVS.__init__(self, "CoupledProcessor_%s_%s" % (it, namecounter)) self.inport = self.addInPort("inport") self.outport = self.addOutPort("outport") if it != 0: self.subproc = self.addSubModel(ClassicCoupledProcessor(it - 1, 0)) else: self.subproc = self.addSubModel(ClassicProcessor(0)) self.subproc2 = self.addSubModel(ClassicProcessor(1)) if it != 0: self.subproc3 = self.addSubModel(ClassicCoupledProcessor( it - 1, 2)) else: self.subproc3 = self.addSubModel(ClassicProcessor(2)) self.connectPorts(self.inport, self.subproc.inport) self.connectPorts(self.subproc.outport, self.subproc2.inport) self.connectPorts(self.subproc2.outport, self.subproc3.inport) self.connectPorts(self.subproc3.outport, self.outport)
def __init__(self): CoupledDEVS.__init__(self, "Factory") self.cylinder_source = self.addSubModel(CylinderSource(seed=10.0)) self.cube_source = self.addSubModel(CubeSource(seed=20.0)) self.preassembler = self.addSubModel(Preassembler()) self.assembler = self.addSubModel(Assembler()) self.inspector = self.addSubModel(Inspector()) self.fix = self.addSubModel(Fix()) self.accept = self.addSubModel(Accept()) self.trash = self.addSubModel(Trash()) self.connectPorts(self.cylinder_source.outport, self.preassembler.inport) self.connectPorts(self.cube_source.outport, self.preassembler.inport2) self.connectPorts(self.preassembler.outport, self.assembler.inport) self.connectPorts(self.assembler.outport, self.inspector.inport) self.connectPorts(self.inspector.outport, self.accept.inport) self.connectPorts(self.inspector.outport2, self.fix.inport) self.connectPorts(self.inspector.outport3, self.trash.inport) self.connectPorts(self.fix.outport, self.assembler.inport)
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)
def __init__(self, mu, size, num, procs): CoupledDEVS.__init__(self, "QueueSystem") # Define all atomic submodels of which there are only one generator = self.addSubModel(Generator(mu, size, num)) queue = self.addSubModel(Queue(len(procs))) collector = self.addSubModel(Collector()) self.connectPorts(generator.out_event, queue.in_event) # Instantiate desired number of processors and connect processors = [] for i, param in enumerate(procs): processors.append(self.addSubModel( Processor(i, param))) self.connectPorts(queue.out_proc[i], processors[i].in_proc) self.connectPorts(processors[i].out_finished, queue.in_finish) self.connectPorts(processors[i].out_proc, collector.in_event) # Make it accessible outside of our own scope self.collector = collector
def __init__(self, nodes, totalAtomics, iterations): CoupledDEVS.__init__(self, "AutoDistChain") self.generator = self.addSubModel(CoupledGenerator(1.0)) self.processors = [] have = 0 ta = 0.66 for i in range(nodes): shouldhave = (float(i + 1) / nodes) * totalAtomics num = int(shouldhave - have) have += num if i == 0: self.processors.append( self.addSubModel( CoupledHeavyProcessor(ta, num, iterations, "HeavyProcessor_" + str(i)))) else: self.processors.append( self.addSubModel( CoupledHeavyProcessor(ta, num, iterations, "HeavyProcessor_" + str(i)), i)) self.connectPorts(self.generator.outport, self.processors[0].inport) for i in range(len(self.processors) - 1): self.connectPorts(self.processors[i].outport, self.processors[i + 1].inport)
def __init__(self): CoupledDEVS.__init__(self, "CQueue") self.generator = self.addSubModel(Generator()) self.queue = self.addSubModel(Queue()) self.connectPorts(self.generator.outport, self.queue.inport)
def __init__(self): CoupledDEVS.__init__(self, "Coupled") self.generator = self.addSubModel(ClassicGenerator()) self.processor = self.addSubModel(ClassicCoupledProcessor(3, 0)) self.connectPorts(self.generator.outport, self.processor.inport)
def __init__(self): CoupledDEVS.__init__(self, "Two") self.generator = self.addSubModel(CoupledGenerator(1.0), 1) self.processor1 = self.addSubModel(CoupledProcessor(0.30, 3)) self.connectPorts(self.generator.outport, self.processor1.inport)
def __init__(self): CoupledDEVS.__init__(self, "Root") self.lower = self.addSubModel(DoubleLayer2()) self.generator = self.addSubModel(Generator("Generator", 1)) self.connectPorts(self.generator.outport, self.lower.inport1) self.connectPorts(self.generator.outport, self.lower.inport2)
def __init__(self): CoupledDEVS.__init__(self, "Layer1") self.inport = self.addInPort("inport") self.processor = self.addSubModel(Processor("Processor", 0.3)) self.connectPorts(self.inport, self.processor.inport)
def __init__(self): CoupledDEVS.__init__(self, "ParallelLocalChain") self.processor1 = self.addSubModel(LocalLong('Local1')) self.processor2 = self.addSubModel(LocalLong('Local2'))
def __init__(self, name): CoupledDEVS.__init__(self, name) self.generator = self.addSubModel(Generator("Generator", 1)) self.processor1 = self.addSubModel(CoupledProcessor(0.66, 20)) self.connectPorts(self.generator.outport, self.processor1.inport)
def __init__(self): CoupledDEVS.__init__(self, "Nested") self.generator = self.addSubModel(Generator("Generator", 1)) self.processor = self.addSubModel(NestedProcessor("NProcessor")) self.connectPorts(self.generator.outport, self.processor.inport)
def __init__(self, ta): CoupledDEVS.__init__(self, "DualChainMP") self.generator = self.addSubModel(CoupledGenerator(1.0), 1) self.processor1 = self.addSubModel(CoupledProcessorMP(0.66), 2) self.connectPorts(self.generator.outport, self.processor1.inport)
def __init__(self, ta): CoupledDEVS.__init__(self, "DualDepth") self.generator = self.addSubModel(Generator("Generator", 1.0)) self.processor = self.addSubModel(DualDepthProcessor(ta), 1) self.connectPorts(self.generator.outport, self.processor.inport)