Simulating a Labor and Delivery Unit whose Inter-arrival distributions are dependent on weekday

1,055 views
Skip to first unread message

craigm...@mac.com

unread,
Nov 10, 2014, 6:48:24 PM11/10/14
to jaamsi...@googlegroups.com
All,
I've built a resource consumption model to illustrate the room utilization in my labor and delivery center at my hospital in order to show the need to invest in additional post-partum rooms. While the model works very well (thanks ausenco) it needs to be tightend up.

How can I model two different arrival rates that correspond to weekdays and weekends?

I'm thinking it's a branch object, but after reviewing the code, I can't figure out the dot operator on the clock to be able to test the current time for weekday or weekend.

Thank you for any and all help.

Warm Regards,
Craig

Harry King

unread,
Nov 10, 2014, 8:13:17 PM11/10/14
to jaamsi...@googlegroups.com
Craig,

You can use a TimeSeries object to specify the changes in the arrival rate. The EntityGenerator keyword "InterArrivalTime" will accept the TimeSeries as its input. This will generate a uniform stream of arrival with one rate for weekdays and another for weekends, or any more complicated variation you want to specify in the TimeSeries.

To randomize the arrival pattern, you can feed the uniform stream into an EntityDelay with some random distribution for its "Duration" input. You will need to experiment with the random delay until you get the arrival stream statistics you want.

Another way to randomize the arrival pattern is to use a random distribution that can accept a TimeSeries for its appropriate keywords (for example "Mean" in the case of the NormalDistribution). We haven't programmed this ability yet, but it would be possible to do so quite quickly if it is needed. This approach is valid as long as the interarrival time is always much smaller that the time scale for rate changes (i.e. the quasi-static approximation).

I can help you carry out these ideas if you post your model to the forum.

By the way, your post mentions the dot operator on the clock -- can you explain what you are trying to do in more detail?

Harry

craigm...@mac.com

unread,
Nov 10, 2014, 10:17:16 PM11/10/14
to jaamsi...@googlegroups.com
Harry,

In regards to the dot operator for the clock object, I was thinking I was going to have to use a logical test on a getter for the clock object, i.e. clock.getCurrentTime().  If that was the case I was curious what other getters might be available for the clock object.

My initial attempt used an exponential distribution as the arrival process.  I varied the lambda figure in order to increase the total number of deliveries per year.  What I think I'd really like to do is to call the distribution from the value section of the time series object.  Something like this:  { { 2014-01-01T00:00:00 [weekdayArrivals] } { 2014-01-06T00:00:00 weekendArrival } } and cycleTime of 7 d.  

I've attempted to upload the .cfg file, but get an error on each attempt.  What am I missing?  

Thanks again for all of your help!

Warm Regards,
Craig

Harry King

unread,
Nov 10, 2014, 11:24:40 PM11/10/14
to jaamsi...@googlegroups.com
Craig,

All the available outputs for each object are listed in the Output Viewer. You can reference the one you want in an expression using the dot notation: [ObjectName].OutputName. Don't use the clock object to get the simulation time -- it is just an object that displays the simulation time in a particular format. Every object has an output called "SimTime", which is the present simulation time in seconds.

By the way, don't rely on SimTime to trigger an event using an expression. Expressions are only evaluated on demand. Use a TimeSeries if you want to trigger an action at a specific time. However, you can use an SimTime in an expression that is an input to the InterArrivalTime keyword for your EntityGenerator. The expression is re-evaluated every time the generator dispatches an entity.

The TimeSeries object can only return a number -- it can't be used to return an object such as an arrival distribution.

I trust that the above answers all your questions. Feel free to ask more!

Harry

Harry King

unread,
Nov 13, 2014, 1:07:15 AM11/13/14
to jaamsi...@googlegroups.com
Craig,

I've attached a revised version of the model you emailed me. The error message you got on start up indicated a problem with your TimeSeries -- you need to provide the sequence of times and output values, using the keyword "Value". I've added the following input for this keyword:

{  0  s  4  min  }  {  '0000-01-06 00:00:00'  3  min  }

The first entry says that the initial value for the TimeSeries is 4 minutes.  The second entry says that at midnight on Saturday morning, the value for the TimeSeries changes to 3 minutes. Note that you can use mix and match the various notations for time inputs.

The next step is to set the keyword "CycleTime" to 7 d (i.e. 7 days), so that the pattern repeats every week. That is, for Monday - Friday, the value is 4 minutes and on Saturday - Sunday it is 3 minutes.

I hope this helps to get you started.

Harry
CyFairLabor&Delivery-HK.cfg

Craig Maxey

unread,
Dec 9, 2014, 3:32:20 PM12/9/14
to Harry King, jaamsi...@googlegroups.com
Harry,

I finally got back to this project. I used your model to create a series of simulations to test out different scenarios and my leadership really liked the insights. As we were discussing the model it became apparent that I need to add two additional arrival streams. On describing scheduled c-sections, and one describing scheduled inductions. My goal is to have these arrival rates seize either c-section rooms or LDR rooms directly. Unfortunately, I’m getting an error and I can’t seem to figure out why. Can I not have multiple streams seize resources?

Thanks for your help!

Warm Regards,
Craig



CyFairLabor&Delivery-HK v2.cfg

Harry King

unread,
Dec 9, 2014, 10:23:14 PM12/9/14
to jaamsi...@googlegroups.com, d.harr...@gmail.com, craigm...@me.com
Craig,

This one is my fault. We changed the ReportGenerator object recently so that it uses the inputs to the Simulation keywords "InitializationDuration" and "RunDuration". The ReportGenerator keywords "InitializationDuration" and "RunDurationList" are not supported any more.

To fix this, just load the file, enter the new inputs for the Simulation keywords, and re-save the file. JaamSim will ignore the old ReportGenerator inputs after printing the error messages.

By the way, if you get an input message on loading a configuration file, just look at the corresponding .log file. The error message will be printed right below the offending line.

Harry

Craig Maxey

unread,
Dec 9, 2014, 10:41:58 PM12/9/14
to Harry King, jaamsi...@googlegroups.com
Harry,
I kept playing with the model and realized that the errors only occured when I I used a time series with an initial arrival rate of 0.  i.e. {‘0000-01-01’ 00:00:00 0 h} {‘0000-01-01’ 08:00:00 1 h} to signify that I don’t want any arrivals from midnight until 0800 on the first day and then 1 arrival per hour from there on out.  I was able to get the simulation to run if I tricked the system and said I only wanted an arrival every 8 hours and then changed the rate  to 1 h at 0800.  

What I’m attempting to do is simulate scheduled arrivals for a period of time during weekday mornings.  Any other tricks of the trade you have for me?  

Thanks again!

Warm Regards,
Craig


--
You received this message because you are subscribed to a topic in the Google Groups "Jaamsim Users Discussion Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jaamsim-users/0hLc7iQoTS4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jaamsim-user...@googlegroups.com.
Visit this group at http://groups.google.com/group/jaamsim-users.
To view this discussion on the web, visit https://groups.google.com/d/msgid/jaamsim-users/19b3908c-abda-424f-bbe3-852dc8d08965%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Harry King

unread,
Dec 9, 2014, 11:42:05 PM12/9/14
to jaamsi...@googlegroups.com, d.harr...@gmail.com, craigm...@me.com
Craig,

The problem is that the EntityGenerator keyword "InterArrivalTime" means the time between the creation of subsequent entities. If it goes to zero, you will try to create an infinite number of entities and the program loops furiously. Clearly, we need to protect against this better in the code!

Your workaround is the right way to handle the situation if you want to use the InterArrivalTime keyword. A better way to do this would be to use a TimeSeriesThreshold in the OperatingThresholdList input to turn the EntityGenerator off between 00:00 and 08:00, etc. I've tried this in the attached file.

Harry
CyFairLabor&Delivery-HK v3.cfg

Zach Kaylor

unread,
Jan 15, 2015, 10:22:55 AM1/15/15
to jaamsi...@googlegroups.com, d.harr...@gmail.com, craigm...@me.com
Sorry to revive such a dead thread.  I am interested in distributions being able to accept a Timeseries for its inputs (as Harry mentioned in his first post in the thread).  

Has this already been implemented?  Are there plans to implement it in the future?

Harry King

unread,
Jan 15, 2015, 2:49:09 PM1/15/15
to jaamsi...@googlegroups.com, d.harr...@gmail.com, craigm...@me.com
Zach,

We haven't implemented the ability for a probability distribution to accept a TimeSeries as an input, yet. However, any input that accepts a probability distribution will also accept an expression, so you could scale and offset your probability distribution as required. When done correctly, this method is equivalent to changing the mean and/or standard deviation for the distribution.

For example, you could enter the following expression as an input for the InterArrivalTime keyword for an EntityGenerator:
'[ExponentialDistribution1].Value * [TimeSeries1].PresentValue'

This might actually be the preferred method for modelling a variable probability distribution. Does anyone have an opinion on this?

Harry

Zach Kaylor

unread,
Jan 15, 2015, 4:40:10 PM1/15/15
to jaamsi...@googlegroups.com, d.harr...@gmail.com, craigm...@me.com
Harry, I appreciate your response.

I will definitely be using your advice with the expressions in the short term in order to approximate the variability I need over time.   I still think that it would be easier to use TimeSeries as an input for a distribution.  I say this because I would like to vary the mean and the standard deviation at different rates (though not so different that your suggestion won't give me a relatively accurate approximation).  

Perhaps I am looking at this the wrong way.  In any case I will happily make use of your suggestion until a better option presents itself.

Thanks,
Zach

Harry King

unread,
Jan 15, 2015, 5:20:19 PM1/15/15
to jaamsi...@googlegroups.com, d.harr...@gmail.com, craigm...@me.com
Zach,

My uneasiness about allowing variable inputs for probability distribution is that they are likely to be misused. If you want to generate random arrivals with a variable arrival rate then simply varying the mean for the distribution is okay only if the value varies slowly compared to the inter-arrival time -- i.e. the quasi-static approximation. A much more complicated entity generator is needed to do it properly for the general case. Look up "Nonstationary Poisson Process" for more information.

What kind of system do you want to model?

Harry

Craig Maxey

unread,
Jan 16, 2015, 8:24:43 AM1/16/15
to Harry King, jaamsi...@googlegroups.com
Zach,
I used Harry's suggestion in my model and it was a reasonable approximation and, once I understood the nuances of JAAMSIM, the implementation and execution were relatively easy. I'll provide the model once I am back to a computer.

Regards,
Craig

Sent from my iPhone

Zach Kaylor

unread,
Jan 16, 2015, 9:24:21 AM1/16/15
to jaamsi...@googlegroups.com, d.harr...@gmail.com, craigm...@me.com
Thanks for the responses guys.

I am modeling a call center where the calls arrive at differing rates depending on the time of day.

Harry you were right to suggest reading up on "Non-stationary Poisson Process", this is very similar to the type of situation I am trying to model.

Craig,  I appreciate your willingness to share your model with me.  I look forward to seeing it!

Harry King

unread,
Jan 16, 2015, 4:43:06 PM1/16/15
to jaamsi...@googlegroups.com, d.harr...@gmail.com, craigm...@me.com
Zach and Craig,

Now that there are two people who want this function, I've started to think about how we can provide it.

It should be possible to create a new object for generating non-stationary Poisson arrivals that uses a TimeSeries to specify the instantaneous arrival rate. The generalized exponential distribution would be included inside this object. In this case, I don't think that it is possible to separate the random distribution from the generator because the algorithm is specific to non-stationary Poisson arrivals -- it cannot be generalized to other generation process or probability distribution.

This would be really useful addition to JaamSim and something that is not provided by most if not all other simulation packages.

Harry

Harry King

unread,
Apr 18, 2015, 3:42:01 PM4/18/15
to jaamsi...@googlegroups.com, craigm...@me.com, d.harr...@gmail.com
Zach and Craig,

Time-varying entity generation is now supported in release 2015-15 by the new NonStatExponentialDist object in the the Probability Distributions palette. As the name suggests, it uses the correct "non-stationary Poisson process" algorithm. An example is provided in another post.

Although the new object was easy enough to program, the hard part turned out to be the TimeSeries object, which needed a big clean-up.

Harry

Al Taliaferro

unread,
Jun 29, 2015, 4:19:09 PM6/29/15
to jaamsi...@googlegroups.com
I am interested in scheduling arrivals by day of week, also, but I believe I have found an issue in the proposed solution given in this example model. If I change TimeSeries1 in the attached model to an infinite arrival time in order to simulate lack of arrivals on the weekends then it appears that the cycle does not ever reset. After the first cycle I do not receive any more arrivals on the EntityGenerator controlled by TimeSeries1.


Please advise.

(Thanks!)
CyFairLabor&Delivery-HK v3.cfg

Al Taliaferro

unread,
Jun 29, 2015, 4:30:50 PM6/29/15
to jaamsi...@googlegroups.com
I should note that I have a workaround that involves branching logic and setting a start day for the week, but it seems like there must be a more elegant solution. My example that honors a recurring day of the week pattern is attached (with a different model.)
Processing_queue_test_v010.cfg

Harry King

unread,
Jun 29, 2015, 4:54:55 PM6/29/15
to jaamsi...@googlegroups.com
Al,

You need to use the NonStatExponentialDist object along with a TimeSeries to model an arrival rate that varies with time. Trying to do it any other way and you run into the problem that you reported or, at best, inaccurate results. The earlier posts to/from Zach and/or Craig will provide you with some background info.

The attached example shows how to use the NonStatExponentialDist in a model. Note that the TimeSeries must contain the expected total number arrivals at each given time, not the arrival rate.

Harry
NonStatExponentialDist Example.cfg

Al Taliaferro

unread,
Jun 29, 2015, 6:12:29 PM6/29/15
to jaamsi...@googlegroups.com
Thank you for the quick response, but the example file generates an error for me that I cannot seem to clear:
"TimeSeries1: CycleTime must be larger than the last time in the series."


Harry King

unread,
Jun 29, 2015, 7:55:35 PM6/29/15
to jaamsi...@googlegroups.com
Al,

The example works correctly with the latest release -- 2015-25.

For your model, the CycleTime input should be 7 d if you want your arrival pattern to repeat each week. If you want your arrival rate to change for each day of the week, the Value input should have 8 entries, starting with { 0 h 0 }. The last entry should be { 7 d x } where x should be replaced by the expected number of arrivals per day.

If, for example, you want an average of 100 arrivals on Monday and 50 arrivals on each day for the rest of the week, then the input for Value should be:
{ 0 d 0 } { 1 d 100 } { 2 d 150 } { 3 d 200 } { 4 d 250 } { 5 d 300 } { 6 d 350 } { 7 d 400 }

Note that this input will give you a constant arrival rate for each day, between 00:00 and 24:00. Add more entries to your TimeSeries if you want the arrival rate to vary over each day.

Harry

panc...@gmail.com

unread,
Jul 7, 2015, 2:54:37 PM7/7/15
to jaamsi...@googlegroups.com
Harry,

I tried the approach you outlined on Nonstationary Exp distribution object -- I was hoping that the entity counts (generated by the entity generator) will be close to the counts in the (input) timeseries but comes significantly less -- any advice to close the gap

Thanks

Venkat

Harry King

unread,
Jul 7, 2015, 4:31:02 PM7/7/15
to jaamsi...@googlegroups.com, panc...@gmail.com
Venkat,

Remember that the TimeSeries specifies the cumulative arrivals (average total arrivals to that time), not the arrival rate (average arrivals per unit time).

If that aspect isn't the source of the problem, then please post your input file so that I can find out what is going wrong. If you prefer, you can email the file to me rather than posting it.

Harry

Harry King

unread,
Jul 8, 2015, 12:54:34 AM7/8/15
to jaamsi...@googlegroups.com, panc...@gmail.com
Venkat,

I've tried the model you emailed me and it seems to be working correctly:

- the ED patients are supposed to arrive at an average rate of 130 patients in 572 hours, or about 0.227 patients/h
- the OtherED patients are supposed to arrive at an average rate of 43 patients in 654 hours, or about 0.066 patients/h

The values of 130 in 572 hours and 43 patients in 654 hours are taken from the last entries for the TimeSeries keyword "Value".

The 2,000 hour simulation run generated 426 ED patients or about 0.213 patients/h -- slightly less than the long term average. A total of 131 OtherED patients were generated or about 0.066 patients/h -- very close to the long term average.

When I increased the run duration to 1,000,000 hours, the average number of patients was almost exactly equal to the long term average values.

Incidentally, the Output Viewer will display the average patient generation rates in patients/hour if you append the unit /h to input for the Simulation keyword "DisplayUnits".

Harry

Reply all
Reply to author
Forward
0 new messages