def main(self): c = Create(15) c.setDistribution('exp') c.setName('creator') p0 = Doctor(0, 0, 2) p0.setName('doctors') p0.setDistribution('exp') p1 = Process(3, 8, 3) p1.setName('chambers') p1.setDistribution('unif') #p1.setDistribution('exp') p2 = Process(3, 4.5, 1) p2.setName('registration') #p2.set_distribution('erlang') p2.setDistribution('exp') #p2.maxQueue = 2 p3 = Labs(2, 4, 2) p3.setName('lab') p3.setDistribution('exp') #p3.set_distribution('erlang') #p0.chambers = p1 #p0.registration = p2 c.nextElement = p0 p0.setNextElements([p1, p2]) p2.setNextElements([p3]) p3.setNextElements([p0]) elementsList = [c, p0, p1, p2, p3] model = Model(elementsList) model.simulate(10000.0)
def main(self): c = Create(.5) p1 = Process(1.0, 2) p21 = Process(4.0, 1) p22 = Process(3.0, 2) p3 = Process(1.2, 1) print('id0 = {} id1= {} '.format(c.getId(), p1.getId())) c.setNextElement(p1) p1.setMaxqueue(5) p21.setMaxqueue(3) p22.setMaxqueue(2) p3.setMaxqueue(2) c.setName('CREATOR') p1.setName('PROCESSOR1') p21.setName('PROCESSOR21') p22.setName('PROCESSOR22') p3.setName('PROCESSOR3') c.setDistribution('exp') p1.setDistribution('exp') p21.setDistribution('exp') p22.setDistribution('exp') p3.setDistribution('exp') p1.setNextElements([p21, p22]) p21.setNextElements([p3]) p22.setNextElements([p3]) elementsList = [c, p1, p21, p22, p3] model = Model(elementsList) model.simulate(1000.0)
def main(self): c = Create(2) p1 = Process(.6, 1) p2 = Process(.3, 1) p3 = Process(.4, 1) p4 = Process(.1, 2) print('id0 = {} id1= {} '.format(c.getId(), p1.getId())) c.setNextElement(p1) c.setName('CREATOR') p1.setName('PROCESSOR1') p2.setName('PROCESSOR2') p3.setName('PROCESSOR3') p4.setName('PROCESSOR4') c.setDistribution('exp') p1.setDistribution('exp') p2.setDistribution('exp') p3.setDistribution('exp') p4.setDistribution('exp') p1.setNextElements([p2, p3, p4, None]) p1.elementsProbabilities = [0.15, 0.13, 0.3, 0.42] p2.setNextElements([p1]) p3.setNextElements([p1]) p4.setNextElements([p1]) elementsList = [c, p1, p2, p3, p4] model = Model(elementsList) model.simulate(1000000.0) res = model.returnResult() res['theoretical_mean_queue'] = [1.786, 0.003, 0.004, 0.00001] res['theoretical_workload'] = [0.714, 0.054, 0.062, 0.036] res['queue_accuracy'] = 100 * ( abs(res.eval('mean - theoretical_mean_queue')) / res['theoretical_mean_queue']) res['workload_accuracy'] = 100 * ( abs(res.eval('workload - theoretical_workload')) / res['theoretical_workload']) print(res)
def main(self): p11 = Process(.3, .3, 1) p12 = Process(.3, .3, 1) p11.otherProcess = p12 p12.otherProcess = p11 c = Create(.5) c.setNextElements([p11, p12]) p11.setMaxqueue(3) p12.setMaxqueue(3) p11.state = 1 p12.state = 1 c.tnext = 0.1 p11.queue = 2 p12.queue = 2 c.setName('CREATOR') p11.setName('PROCESSOR21') p12.setName('PROCESSOR22') c.setDistribution('exp') p11.setDistribution('exp') p12.setDistribution('exp') elementsList = [c, p11, p12] model = Model(elementsList) model.simulate(10000.0)