Waiting times in a doctor's surgery

Use this forum to post Vensim related questions.
Post Reply
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Waiting times in a doctor's surgery

Post by nikvyas »

Good day everyone.

I've built models in Vensim for a number of years now, but have never used Queues. The problem I have at the moment however, probably lends itself to Queues.

I want to model the maximum waiting time for each patient who comes in and waits to be seen at a doctor's surgery. The patients will arrive, irregularly, throughout the morning and will then wait until they are able to be seen by a doctor. There are only a finite of doctors and each appointment takes ten minutes on average. I'm pretty sure that I want to model each patient as a subscript and the Queue will be FIFO. I want to know the maximum length of time each patient will need to wait to be seen by a doctor. I suspect it's quite a straightforward solution for the experts on here.

Any help gratefully appreciated.

Thanks

Nik
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Re: Waiting times in a doctor's surgery

Post by nikvyas »

The attached doesn't work because at the moment it does the following.......

Once the average length of appointment is reached, patients are "seen" every minute depending on the number of doctors. i.e., in the attached, the number of doctors is 4. So, after the "average length of appointments" is reached (ten minutes), a maximum of 4 patients is seen every minute. But this isn't what I want. What I actually want is as follows........

If the number of patients coming in at time t=0 is ten. Because none of the doctors are currently occupied, 4 patients are seen immediately and the others will wait. At time t=10 (the length of the appointment) the four patients have completed their appointments and (up to) 4 more can then be seen (for another ten minute appointment). If there are other patients waiting, then (up to) 4 more will be seen at time t=30 etc etc until all of the patients have been seen. Patients can come in at any time, so they will work on FIFO basis. One thing I will need to know is the average waiting time of each of the patients.

All help gratefully received.
Attachments
patients.mdl
(2.52 KiB) Downloaded 272 times
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Re: Waiting times in a doctor's surgery

Post by nikvyas »

I guess the easiest thing to do (and I know I'm talking to myself a bit here) is to set the number of doctors to:

number of doctors / length of appointment = 0.4

This way only 0.4 of a patient can be seen in a minute.

Not particularly elegant .......... and will it give a correct answer, particularly wrt average waiting time?
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Waiting times in a doctor's surgery

Post by Administrator »

The model as you have it is too simple.

You need to have a variable that is "doctors free". This goes up or down depending on a level that is called "patients being seen". Once "patients being seen" goes below the number of doctors, you can remove that much from the queue and place them in the level "patients being seen". Patients spend "average length of appointment" in "patients being seen". What you are doing is removing patients from the queue based on the number of doctors, this will not be true in reality.

So change "patients seen" to be "patients allocated". Calculate this based on the number of doctors that are free.

It's also a really really good idea to put units in your model. They show up all sorts of common errors (personally, I consider it a complete waste of time working with a model that does not pass this basic check).
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Waiting times in a doctor's surgery

Post by tomfid »

Here's an alternate implementation, with units:
patients.mdl
(3.46 KiB) Downloaded 323 times
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Waiting times in a doctor's surgery

Post by gwr »

While this may go a bit astride, I would like to ponder a bit more regarding the QUEUE FIFO and QUEUE FIFO ATTRIB since they have also been suggested as a possible solution to modeling an aging chain using a cohort & conveyor approach (cf. my post).

Question 1:
As far as I understand it one could have a coflow structure (e.g. one for the stock and one for its attribute) using conveyors (without leakage here) and thus have a FIFO-process with a pipline delay (= infinite order). Now as far as I have understood it sofar, the QUEUE FIFO is similar but the outflow of the elements and attributes (keeping the order of entering) will be an exponential delay (=first order delay). Is that perception correct?

Question 2:
Is it possible to have a FIFO-process with an k-order delay which would then be the general case (with possible k going from 1 to infinity) keeping track of the attributes in a similar way as it is supposedly done using the QUEUE FIFO function?

Kind regards,

Guido
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Re: Waiting times in a doctor's surgery

Post by nikvyas »

Many thanks Tom.

Note that there is a slight error in your model.

patients seen = MIN(max patients seen,patients waiting)

and not

patients seen = MIN(max patients seen,patients waiting/average length of appointment)

Many thanks

Nik
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Waiting times in a doctor's surgery

Post by Administrator »

I don't think there is an error in Tom's model. Make your change and then use the units check. Then look in a little more detail at the structure. Tom's model is correct.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Re: Waiting times in a doctor's surgery

Post by nikvyas »

No, you'll find you're wrong.

Don't just look at the units, look at the outputs.
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Questions regarding QUEUE FIFO

Post by gwr »

Obviously my questions above have been somewhat disregarded here. Should I better open a new thread for them?

Guido
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Waiting times in a doctor's surgery

Post by Administrator »

I think it best to open a new thread Guido. Otherwise things get off topic.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Waiting times in a doctor's surgery

Post by gwr »

Many thanks Tom.

Note that there is a slight error in your model.

patients seen = MIN(max patients seen,patients waiting)

and not

patients seen = MIN(max patients seen,patients waiting/average length of appointment)

Many thanks

Nik
Hi Nik,

there is indeed no error in Tom's model. A basic consideration: To prevent a negative (and thus incorrect) level the total outflow at any time step must not be higher than

amount in the stock / time step

as this would drain the stock completely in the next time step. Your suggestion of having the amount of patients wating (e.g. the amount in the stock) only as outflow restriction implicitly assumes an outflow of patients waiting / 1 Unit of Time. From non-negativity postulations every rate is feasible within the range

0 <= rate of outflow <= amount in the stock [time] / time step*

( or rather the smalles possilbe time step at time used by the numerical integration algorithm)

So solely for non-negativity the restriction should be the amount in the stock divided by the smallest possible span of time for that amount to drain in a simple first order process (e.g. exponential decay) which has the most "dramatic" outflow profile.

Kind regards,

Guido
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Waiting times in a doctor's surgery

Post by tomfid »

Other ways to look at this:

1. dimensional consistency

equating patients seen = MIN(max patients seen,patients waiting) mixes items with units of people and people/minute.

2. implicit time constants

patients seen = MIN(max patients seen,patients waiting)

and

patients seen = MIN(max patients seen,patients waiting/average length of appointment)

are equivalent for average length of appointment = 1 time unit (as in Guido's comment). But if appointment length <> 1, the relationship between patients waiting and patients seen will not obey Little's Law, which is a problem. http://en.wikipedia.org/wiki/Little%27s_law

However, if you want to see patients discretely (i.e. integer people), then patients seen = patients waiting makes more sense conceptually. The notation is a bit different, because this is not quite standard SD flows, but dimensional consistency still must apply. See http://models.metasd.com/rental-car-sto ... -dynamics/ for a possible example.
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Re: Waiting times in a doctor's surgery

Post by nikvyas »

Thanks Guido, Tom.

My problem is this.

You've already specified that

max patients seen = 0.4

because the number of doctors is 4 and the length of an appointment 10 minutes.

So what this implies to me is that, every time step (a maximum of ) 0.4 of "patients waiting" will be cleared, which makes perfect sense.

i.e, if 4 patients arrived at the same time (t=0), the following would happen:
At t=1, 0.4 patients has been seen and 3.6 is left
At t=2, 0.4 patients has been seen and 3.2 is left
At t=3, 0.4 patients has been seen and 2.8 is left
etc etc so that
At t=10, 0.4 patients has been seen and 0 is left.

This makes sense to me, because the four doctors have seen one patient each so that at t=10, all four have been seen.

This would be (and is) achieved with the equation
MIN(max patients seen,patients waiting)

It isn't achieved with the equation
MIN(max patients seen,patients waiting/average length of appointment)
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Waiting times in a doctor's surgery

Post by tomfid »

I see what you mean. The long tail of the exponential distribution of servicing patients seems weird compared to intuition about the actual process.

However, the solution, MIN(max patients seen,patients waiting), fails two other reality checks. First, if TIME STEP <> 1, it doesn't work; for continuous modeling things should generally work in the limit of TIME STEP->0. Second, in the limit of lots of doctors and few patients, patients get seen in 1 minute rather than 10 minutes.

It's possible to handle all this, but I have to finish writing a proposal tonight. I'll get back to this ASAP, or perhaps someone will beat me to it.
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Re: Waiting times in a doctor's surgery

Post by nikvyas »

Many thanks Tom.
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Re: Waiting times in a doctor's surgery

Post by nikvyas »

Just a reminder about the model modification, when you get a chance Tom.

I have spent the last four days on a WITNESS course and although it seems to me that WITNESS is more suited to the simulation of queues etc, I'm a little reluctant to use it because I much prefer the "feel" of Vensim.
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Waiting times in a doctor's surgery

Post by tomfid »

I'm not familiar with WITNESS, but if it's a discrete event simulator it might be more suitable for some problems. Generally, the dividing line is between tactical/operational control problems, where you really care about distributions and individual elements, and more strategic problems that blend many attributes of an organization - inventory, pricing, quality, consumer perceptions, etc. Vensim is generally the stronger choice for the latter.
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Re: Waiting times in a doctor's surgery

Post by nikvyas »

Yes WITNESS is a discrete simulator developed by Lanner. It is getting a lot of traction within the Company for which I work largely because their salesman are very convincing and very persistent. That is something Ventana can't be accused of (rightly or wrongly).

I suspect that, in general, I don't develop models within Vensim in the conventional (correct?) way. I use it more as a discrete simulator so am wondering if I should begin to develop the kind of models that I develop within WITNESS. So far I have resisted.

I have attached a simple example model. Before I get a hard time, I know that the units are not populated ..... but ......to be honest, I really don't care too much. My priority is in building models that represent reality as far as possible - they are not a university project. The reason I'm attaching the model Tom is to get your opinion on whether or not I'm using Vensim incorrectly.

Could I also ask you to please, please update the doctor's surgery model so that it behaves a bit more realistically?

Thanks

EDIT - file removed 14/07/2013
Last edited by nikvyas on Sun Jul 14, 2013 5:46 pm, edited 1 time in total.
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Waiting times in a doctor's surgery

Post by tomfid »

More options:
patients2.mdl
(10.41 KiB) Downloaded 282 times
Unfortunately, with the runup to the SD conference, I'm super busy so it's tough to keep up, but I'll try to respond to comments.
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Re: Waiting times in a doctor's surgery

Post by nikvyas »

I've had a look at the model you attached Tom.

The model I would want to use is the one with Poisson arrivals. However, "patients waiting 1" is behaving in a peculiar way (i.e. it never decreases). Do I need to change:

QUEUE FIFO(admitting 0+arriving 0, admitting 0, flat, 0, 0 ) to

QUEUE FIFO(arriving 0, admitting 0, flat, 0, 0 )

Thanks

Nik
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Waiting times in a doctor's surgery

Post by tomfid »

I don't have it in front of me (traveling) but I think you're correct - my mistake.
Post Reply