Steven Kennedy | 8 Feb 22:07
Picon
Gravatar

Fwd: Hospital patient flow questions

I always forget to reply-all.

---------- Forwarded message ----------
From: Steven Kennedy <stevenkennedy2263 <at> gmail.com>
Date: Thu, Feb 9, 2012 at 8:00 AM
Subject: Re: [Simpy-users] Hospital patient flow questions
To: "cong k. (kc1g08)" <kc1g08 <at> soton.ac.uk>

Hi Cong,

For question 1:
Your classes that inherit from SimPy.Simulation.Process need to have
at least one function with a "yield" statement. Check your code - I
suspect this is where the error is coming from.

For question 2:
There are probably plenty of ways to do it, but I would model it this way:
1. Your patients are objects with attributes that define what will
happen to them when they go through the hospital processes
2. You will have several Stores that hold the Patient objects (eg.
waiting room, x-ray waiting line, etc)
3. Your generators simply create Patient objects at different rates,
with different attributes (e.g a patient arriving by ambulance may
have a higher likelihood of needing an x-ray). Once the Patient object
is created, they will be put into the WaitingRoom store.
4. Your Triage process has a single PEM which defines what happens to
the patient (ie. what Store they will be placed into next). This
should be based on attributes of the Patient object (eg. if
patient.broken_arm==True: yield put,self,XRayWaitLine,[patient]).
5. You then have other hospital processes (eg. X-Ray) that take
Patient objects from their Store and do something with them.

Hope this helps, and I'd be interested in hearing if other people have
different ways of modelling this scenario.

Steve

On Thu, Feb 9, 2012 at 2:38 AM, cong k. (kc1g08) <kc1g08 <at> soton.ac.uk> wrote:
> Hi Steven,
>
> Thank you for your reply.
>
> Do you have an example for your answer to question 1? It seems if I separate the files I will get a "Activating
function which is not a generator (contains no 'yield')" error.
>
> For your answer in question 2, can multiple generators share the same PEM or share parts of the same PEM? For
example patient 1 arrives via public transport, goes through triage, then nurse assessment; patient 2
arrives via car, goes through the SAME triage, then straight to X-ray room.
>
> Regards,
>
> Kelong
>
>
> On 30 Jan 2012, at 21:03, Steven Kennedy wrote:
>
>> 1. Yes. Create your triage, etc classes in your servers.py file. Make
>> sure servers.py is on your python path. Then just import the server
>> module you've created: "import server" at the start of your main.py,
>> and you can access all the classes using server.triage, etc.
>>
>> 2. You can create multiple generator classes, each of which just
>> creates Patient objects and starts their PEM. The generators can all
>> have different attirbutes (eg. arrival times), and can create all
>> Patients with the same attributes, or modify the attributes of the
>> Patient if you want. eg:
>> class ArrSelf(Process):
>>   ...
>>   def PatientGen(self):
>>       while 1:
>>           yield hold,self,100
>>           p = Patient()
>>           self.sim.activate(p,p.ImHere())
>>
>> class ArrAmbu(Process):
>>   ...
>>   def PatientGen(self):
>>       while 1:
>>           yield hold,self,500
>>           p = Patient()
>>           self.sim.activate(p,p.ImHere())
>>
>> And rather than repeat the same code for all the different ArrX
>> processes, you can create a generic PatientGenerator class, then make
>> the self arrive, ambulance arrive, etc sub-classes of your
>> PatientGenerator, with different attributes for whatever you want to
>> change.
>>
>> 3. You are after the "Store" resource type
>> (http://simpy.sourceforge.net/SimPyDocs/Manuals/Manual.html#stores).
>> These let you store any object type. You then need to write a filter
>> function to be able to select the right object from the Store.
>>
>> 4. I can't remeber any off the top of my head, but most of the
>> concepts are covered here:
>> http://readthedocs.org/docs/simpy/en/latest/Manuals/Examples.html
>>
>> On Tue, Jan 31, 2012 at 2:25 AM, cong k. (kc1g08) <kc1g08 <at> soton.ac.uk> wrote:
>>> Dear SimPy users,
>>>
>>> We're currently making a model for simulating patient flow in a emergency department of a hospital.
There are multiple modes of arrival (by public transport, by ambulance, etc), a large amount of servers
(triage, nurse assessment, doctor assessment), resources and resource pools.
>>>
>>> 1. Is there a way to reuse the same server at different parts of the simulation without wiring the code
again? For instance we want to put all the servers inside one file called servers.py, then call
server.triage or server.nurse in the main.py file.
>>>
>>> 2. Is it possible to simulate multiple modes of arrival at the same time but they all share the same or
similar PEM (servers)? i.e. is something like this valid?
>>>    endTime = 50
>>>    Sim.initialize()
>>>
>>>    pgSelf = ArrSelf.PatientGen()
>>>    pgAmbulance = ArrAmbu.PatientGen()
>>>    pgAmbulatory = ArrAmbulatory.PatientGen()
>>>    pgGP = ArrGPReferred.PatientGen()
>>>
>>>    Sim.activate(pgSelf, pgSelf.generate())
>>>    Sim.activate(pgAmbulance, pgAmbulance.generate())
>>>    Sim.activate(pgAmbulatory, pgAmbulatory.generate())
>>>    Sim.activate(pgGP, pgGP.generate())
>>>
>>>    Sim.simulate(until=endTime)
>>>
>>> 3. Is there a such thing as resource pool (a resource that contains different types of resources) in
SimPy? Where a server can use any of the resource from the resource pool.
>>>
>>> 4. Are there any example that's related to my application, if so where can we find them?
>>>
>>> Regards,
>>>
>>> Kelong
>>> ------------------------------------------------------------------------------
>>> Try before you buy = See our experts in action!
>>> The most comprehensive online learning library for Microsoft developers
>>> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
>>> Metro Style Apps, more. Free future releases when you subscribe now!
>>> http://p.sf.net/sfu/learndevnow-dev2
>>> _______________________________________________
>>> Simpy-users mailing list
>>> Simpy-users <at> lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/simpy-users
>

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d

Gmane