1

Simpy 2.6 を使用して、救急部門の患者の流れを記述するプロジェクトに取り組んでいます。

吸気エリアに 3 人の医師がいるとします。私のプロセスは、ある特定の医師 (たとえば、X 医師) を診察した後、患者は (80% の確率で) 検査室に行くというものです。臨床検査の後、患者はキューに再び参加することで元の医師 X に戻ります。

しかし、どうすれば患者と医師の間のリンクを作成できますか? 現在、私のコードの患者は「無記憶」です - 彼らは実験室のテストの後にランダムな医者に会います. インテークエリアには全部で20床あります。

私を助けてください!前もって感謝します!!

class Intake(Process):
    Queue = [] #patient queue
    Idle = [] #idle PAs list
    Busy = [] #busy PAs list
    Waits=[] #list of wait times, the D2D time
    #Wholetime=[] #list of whole time spent in ED
    IQ = [] #amount in queue when a customer leaves
    NDone = 0 #total number of customers that have been services 
    i = 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 is ready 
            Intake.Idle.remove(self)
            Intake.Busy.append(self)

            while Intake.Queue != []: #perform while customers in queue
                P = Intake.Queue.pop(0) # get 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, the D2D time
    #hQ = [] #amount in queue when a customer leaves
    NDone = 0 #total number of customers that 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 is ready 
            Lab.Idle.remove(self)
            Lab.Busy.append(self)
            while Lab.Queue != []: #perform while customers in queue
                P = Lab.Queue.pop(0) # get customer 
                #Lab.hQ.append(len(Lab.Queue))
                ServiceRate2 = 1.0/(P.Severity) #service rate is recipricol of mean service time  #### for 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) 
4

0 に答える 0