Python Simulation Patient-Doctor Link (Simpy, Emergency Department) -
i'm working on project describe patient flow in emergency department using simpy 2.6.
suppose there 3 doctors in intake area. process is, after seeing 1 specific doctor (say, doctor x), patient (with 80% chance) go lab. after lab test, patient return original doctor x rejoining queue.
but how can create link between patient-docotr? right patients in code "memoryless" - see random doctor after lab test. there 20 beds in total in intake area.
please me! thank in advance!!
class intake(process): queue = [] #patient queue idle = [] #idle pas list busy = [] #busy pas list waits=[] #list of wait times, d2d time #wholetime=[] #list of whole time spent in ed iq = [] #amount in queue when customer leaves ndone = 0 #total number of customers have been services = 0 #new; counter of bed occupation def __init__(self): process.__init__(self) intake.idle.append(self) #initially idle def run(self): while intake.i <= 20: # new new new bed yield passivate,self #remain idle until customer ready intake.idle.remove(self) intake.busy.append(self) while intake.queue != []: #perform while customers in queue p = intake.queue.pop(0) # customer intake.i += 1 #new new new bed intake.servicerate1 = 0.1 / (p.severity) intake.waits.append(now() - p.arrivaltime) intake.iq.append(len(intake.queue)) servicetime = g.rnd.expovariate(intake.servicerate1) yield hold,self,servicetime #perform job intake.ndone += 1 if rand() <= 0.8: lab.queue.append(p) if lab.idle != []: reactivate(lab.idle[0]) else: treatment.queue.append(p) intake.i -= 1 if treatment.idle != []: reactivate(treatment.idle[0]) intake.busy.remove(self) intake.idle.append(self) """ lab process (with p=0.8 patients come here)""" class lab(process): queue = [] #patient queue idle = [] #idle pas list busy = [] #busy pas list wholetime=[] #list of whole time spent in ed #waits=[] #list of wait times, d2d time #hq = [] #amount in queue when customer leaves ndone = 0 #total number of customers have been services def __init__(self): process.__init__(self) lab.idle.append(self) #initially idle def run(self): while true: yield passivate,self #remain idle until customer ready lab.idle.remove(self) lab.busy.append(self) while lab.queue != []: #perform while customers in queue p = lab.queue.pop(0) # customer #lab.hq.append(len(lab.queue)) servicerate2 = 1.0/(p.severity) #service rate recipricol of mean service time #### lab servicetime = g.rnd.expovariate(servicerate2) lab.wholetime.append(now() - p.arrivaltime + servicetime) yield hold,self,servicetime #perform job #lab.wholetime.append(now() - p.arriv) lab.ndone += 1 intake.i -= 1 ## new new new bed lab.busy.remove(self) lab.idle.append(self)
Comments
Post a Comment