Stock behaviour difficult to understand

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

Stock behaviour difficult to understand

Post by Ashish_Kumar »

I attach my WIP model, data file (synthetic data), and a results file. In the "CH" view, top right, the stock "CH Patients" has only one inflow, "CH Admissions by case mix and age group", and one outflow, "CH Discharges".

As shown in the results file, for the selected subscript values:
- At time 13: the first admissions happen. There are 7 admissions.
- At time 14: 3 more admissions happen. There are no discharges yet. But, the stock "CH Patients" decreases to 6.5.
Why is this happening?

(There are hidden links to CH Patients to set the initial value of the stock).
Attachments
Results.xlsx
(17.26 KiB) Downloaded 15 times
CHoF Model.xlsx
(27.29 KiB) Downloaded 10 times
CFoH 1a v1F.mdl
(24.7 KiB) Downloaded 13 times
Administrator
Super Administrator
Posts: 4858
Joined: Wed Mar 05, 2003 3:10 am

Re: Stock behaviour difficult to understand

Post by Administrator »

First thing, when debugging a model, make sure the save period (saveper) is the same as time step. You can do this by editing the equation for saveper, or clicking Model->Settings->Time bounds and ticking "Save results every time step".

You are almost certainly missing results as you are not saving everything.
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
Ashish_Kumar
Member
Posts: 24
Joined: Tue Apr 06, 2021 9:31 am
Vensim version: DSS

Re: Stock behaviour difficult to understand

Post by Ashish_Kumar »

Noted, thanks.

The problem doesn't change when I see results every step, though. The inflow, stock, and outflow don't tally.

What I am trying to do is model inflow as a function of patients transferred to community hospital from acute hospital, constraining inflow to be an integer. Outflow is calculated with DELAY FIXED, based on the length of stay, with a check that outflow does not exceed the stock value. A multiplier is applied to both inflow and outflow to reflect variation in activity by day of week (lower during weekend, higher on Mondays and Fridays etc.)
Administrator
Super Administrator
Posts: 4858
Joined: Wed Mar 05, 2003 3:10 am

Re: Stock behaviour difficult to understand

Post by Administrator »

It's important to try and understand how levels/rates are calculated and used in Vensim.

stock (time) = stock (time-time step) + sum of rates * time step

Given you have a small time step, the value of "CH Patients" increases slowly.

Do you need to add all 7 patients into the "CH Patients" stock in a single time step?
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
Ashish_Kumar
Member
Posts: 24
Joined: Tue Apr 06, 2021 9:31 am
Vensim version: DSS

Re: Stock behaviour difficult to understand

Post by Ashish_Kumar »

Thanks. For the benefit of others, I found this useful when I went through it last year:
https://www.youtube.com/watch?v=6pvJhKA0BmU

In this case, part of the model is discrete (I also have another post about the same model; I thought the two topics were not related:)). I do need the 7 patients (or whatever the number is) to get in in one time step. I realised one way to do this is have time-step = 1.

In any case, the solution will come from aligning the stock equations so that they account for the the form you've written above. E.g., I guess I could use the INTEG equation in my stocks with 1/ TIME STEP.
tomfid
Administrator
Posts: 4019
Joined: Wed May 24, 2006 4:54 am

Re: Stock behaviour difficult to understand

Post by tomfid »

You might also check out this:
https://vensim.com/video/#DS1_Discrete_Events
Post Reply