Modelling small discrete flows

Use this forum to post Vensim related questions.
Post Reply
Ashish_Kumar
Member
Posts: 24
Joined: Tue Apr 06, 2021 9:31 am
Vensim version: DSS

Modelling small discrete flows

Post by Ashish_Kumar »

I attach a first-cut model of Acute Hospital (AH) and Community Hospital (CH) utilisation. The unit of time is a day in this model. Since ~4% of AH patients transfer to CHs, modelling the flows by expressing them in the form that I have in the model does not produce any CH transfers.

I was considering using an accumulator for fractional patient flows, which results in patient flows when the accumulator crosses an integer value. I could also re-work this in completely NetLogo, but the stakeholder is mainly interested in Length of Stay and patient discharges, and not so much in individual and interaction views. The four outcome measures of interest are system-level AH and CH LOS and discharges for AH and CH, as the population ages.

I am looking for suggestions on how to approach this in Vensim.
Attachments
CFoH 1a v1.mdl
(15.47 KiB) Downloaded 22 times
tomfid
Administrator
Posts: 4019
Joined: Wed May 24, 2006 4:54 am

Re: Modelling small discrete flows

Post by tomfid »

I think to do this right, you need to randomize the small flows rather than accumulating fractional people until you have a whole one.

Examples:
https://vensim.com/2017/01/discrete-stochastic/
https://metasd.com/2017/10/bernoulli-poisson-bar/
tomfid
Administrator
Posts: 4019
Joined: Wed May 24, 2006 4:54 am

Re: Modelling small discrete flows

Post by tomfid »

The downside is that Poisson/binomial processes make the model stochastic, so you need to do regular sensitivity runs to appreciate the diversity in behavior.
tomfid
Administrator
Posts: 4019
Joined: Wed May 24, 2006 4:54 am

Re: Modelling small discrete flows

Post by tomfid »

Can't run this without the data spreadsheet.

Could use units.
Ashish_Kumar
Member
Posts: 24
Joined: Tue Apr 06, 2021 9:31 am
Vensim version: DSS

Re: Modelling small discrete flows

Post by Ashish_Kumar »

Thanks for the pointers.

I attach the data file, with synthetic values.

The CH transfers have to be linked to AH patients admissions. Intuitively, AH flows can be continuous because volumes are large, but CH flows cannot.

This is a really early version. I do plan to use SDM-Doc after I have a first version that I can discuss with my colleagues.
Attachments
CHoF Model.xlsx
(23.91 KiB) Downloaded 20 times
tomfid
Administrator
Posts: 4019
Joined: Wed May 24, 2006 4:54 am

Re: Modelling small discrete flows

Post by tomfid »

This is an example of how I'd tend to do it:
patient xfer discrete 1.mdl
(8.21 KiB) Downloaded 28 times
Ashish_Kumar
Member
Posts: 24
Joined: Tue Apr 06, 2021 9:31 am
Vensim version: DSS

Re: Modelling small discrete flows

Post by Ashish_Kumar »

Thank you! Based on your pointers, I did something similar. I used RANDOM POISSON, with lambda set equal to an expected (fractional) value based on the transfer probability. The results are sentitive to the maximum value, which I am scaling to match actual data.

This is *very* useful -- we have continuous as well as discrete flow in the same model.

I have a question:
When I used the approach recommended in your article (multiplying lambda by TIME STEP and then dividing the result by TIME STEP), I only got results in multiples of 16. (My TIME STEP is 1/16). This is not realistic. I have used a mean lambda without using TIME STEP in the equation, and the results seem okay. What is wrong with an equation of the form below?

Transfers (person/day) = RANDOM POISSON( 0 , Max value of transfer , Expected value of transfers, 0 , 1 , 0 )
tomfid
Administrator
Posts: 4019
Joined: Wed May 24, 2006 4:54 am

Re: Modelling small discrete flows

Post by tomfid »

Multiples of 16 are expected because your time step is 1/16 day. By convention, SD flows are continuous, so 16 people/day causes an accumulation of (16 people/day) * (1/16 day) = 1 person. You can see this in the Euler update for a stock:

people in ER = INTEG( admitting-discharging, ...)

is implemented as

people in ER( t + TIME STEP ) = people in ER( t ) + TIME STEP*(admitting-discharging)

The alternative you propose above will probably give you fractional people in the stocks.

If your model is substantially discrete, there is a way to avoid the confusing hexadecipeople. You can define:

Transfers = RANDOM POISSON( lambda ) ~ people
people in ER = INTEG( -transfers/TIME STEP, ... ) ~ people

Notice that the flow now has the same unit as the stock, because it represents the number of people transferred _per time step_, not the number transferred per unit of time. This means lambda must be,

lambda = expected transfer rate * TIME STEP ~ people
expected transfer rate = ... ~ people/day
tomfid
Administrator
Posts: 4019
Joined: Wed May 24, 2006 4:54 am

Re: Modelling small discrete flows

Post by tomfid »

Another workaround would be to change your time unit to 1 hour - then the problem of large flows per fractional time unit goes away (assuming 1hr is enough precision).

You can then define a day as an alternate TIME BASE for display on graph axes, if needed.
Ashish_Kumar
Member
Posts: 24
Joined: Tue Apr 06, 2021 9:31 am
Vensim version: DSS

Re: Modelling small discrete flows

Post by Ashish_Kumar »

Thank you. This is very useful.

In this round of modelling, I will implement the first option you describe: transfers are based on lambda*TIME STEP and stock of patients is integral of transfers/TIME STEP.

(BTW I do get fractional stocks, which would have been a bit problematic while doing validation with end users.)

In the next round, we could move to hourly modelling, which is also better to add waiting time computation to this problem.
Post Reply