Conveyor and limits in stocks

Use this forum to post Vensim related questions.
Post Reply
kalegria
Junior Member
Posts: 14
Joined: Tue Jan 24, 2017 12:49 pm
Vensim version: DSS

Conveyor and limits in stocks

Post by kalegria »

Hi,
I have people progressing through 3 stages of tuberculosis treatment and then completing treatment in this model. I have made it so that after 3624 days, no new patients enter the system. However, when I do this, the stocks do not behave how they should. Periods 1, 2, and 3 all should go to zero. But there is something about how the conveyor is set up and that i do not understand that is making either Period 1 stock behave strangely (decreases rapidly as expected after day 3624, but then abruptly ceases to decline as fast) OR, periods 2 and 3 stocks only decline a tiny bit (if I choose an alternative input for the conveyor between periods 1 and 2).

The three stocks should get to 0, or at least very close, before day 4530.

Please help. Thank you!
kalegria
Junior Member
Posts: 14
Joined: Tue Jan 24, 2017 12:49 pm
Vensim version: DSS

Re: Conveyor and limits in stocks

Post by kalegria »

Here is the data file, if that helps:
Model+Definition.xlsx
(195.3 KiB) Downloaded 198 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Conveyor and limits in stocks

Post by Administrator »

Can you post the data to go with the model?

It's also a really really good idea to put units/dimensions in your model. It could very easily be a dimensional error causing this.
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
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Conveyor and limits in stocks

Post by Administrator »

I'd suggest simplifying things before going any further. You've got things embedded into equations which makes debugging difficult. For example,
Patients In Period 1 Of Treatment = INTEG ( IF THEN ELSE (Patients In Period 1 Of Treatment>=0.2, "rate of transfer (move) into 1"+rate of treatment initiation+"rate of treatment re-initiation"-rate of death 1-rate of ltfu 1
-Rate Of Progression To Period 2-"rate of transfer (move) from 1", 0), INTIAL PATIENTS IN 1).

Why is there a 0.2? What is it?

There is something similar in "Patients In Period 2 Of Treatment", why is there an IF THEN ELSE embedded in there?

I think if you add dimensions to each variable, you'll probably find a few errors in there.
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
kalegria
Junior Member
Posts: 14
Joined: Tue Jan 24, 2017 12:49 pm
Vensim version: DSS

Re: Conveyor and limits in stocks

Post by kalegria »

I added the IF THEN ELSE because the stocks were getting negative values (past zero). This is how I could fix that. But the conveyor issue was there before. I have uploaded here another version without the IF THEN ELSE in the stocks. Please look at it and answer my question again. And also help me figure out how to make sure that the stocks of people don't get negative values. Thank you.
Attachments
Model+Definition.xlsx
(195.3 KiB) Downloaded 163 times
kalegria
Junior Member
Posts: 14
Joined: Tue Jan 24, 2017 12:49 pm
Vensim version: DSS

Re: Conveyor and limits in stocks

Post by kalegria »

THe second View has the graphs that show the problem very clearly. The top row, graph on the right, that is where the stocks are. Period 1 should be decreasing quickly all the way, and none should go below zero.

Please help. thank you.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Conveyor and limits in stocks

Post by Administrator »

Negative stocks are usually quite easy to fix. For example, look at "Patients Who Were Ltfu During Treatment".

It is drained by rate of death from ltfu, rate of move from community, and "rate of treatment re-initiation".

The equation for "rate of death from ltfu" would usually be something like
rate of death from ltfu = min ( Patients Who Were Ltfu During Treatment*(PROBABILITY OF DEATH AMONG LTFU+"PROBABILITY OF DEATH, NON-TB") , Patients Who Were Ltfu During Treatment / time step )

This actually calculates the minimum of "what I want to remove from the stock" and "what is in the stock".

Moving on to the next rate,
rate of move from community = min ( Patients Who Were Ltfu During Treatment*PROBABILITY OF MOVING AWAY AMONG LTFU , Patients Who Were Ltfu During Treatment / time step - rate of death from ltfu ).

What we have here is the minimum of what we want (Patients Who Were Ltfu During Treatment*PROBABILITY OF MOVING AWAY AMONG LTFU) and what is available (Patients Who Were Ltfu During Treatment / time step - rate of death from ltfu).

Last rate,
"rate of treatment re-initiation" = min ( Patients Who Were Ltfu During Treatment*"PROBABILITY OF TREATMENT RE-INITIATION" , Patients Who Were Ltfu During Treatment / time step - rate of death from ltfu - rate of move from community )


But the first thing you really need to do is add units to your model. It has errors (there are unit errors in the example I have just documented), and there is no point in trying to get calculations when the model contains errors.
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
kalegria
Junior Member
Posts: 14
Joined: Tue Jan 24, 2017 12:49 pm
Vensim version: DSS

Re: Conveyor and limits in stocks

Post by kalegria »

Thank you for your help with the negative values in the stocks. Could you now tell me how to get the same behavior in the stocks for periods 1, 2, and 3 after I stop sending patients into the system please? The graph (second View) shows that period 1 decreases as expected at first, but then continues to decrease at a much slower rate soon after. That should not be happening.

THank you

(I will work on the units as well)
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Conveyor and limits in stocks

Post by Administrator »

kalegria wrote:Thank you for your help with the negative values in the stocks. Could you now tell me how to get the same behavior in the stocks for periods 1, 2, and 3 after I stop sending patients into the system please? The graph (second View) shows that period 1 decreases as expected at first, but then continues to decrease at a much slower rate soon after. That should not be happening.
Not really, as you have conveyors. Are conveyors really the correct thing to use here? Usually with a conveyor, you put something on, it moves along before coming off. This is not what you have here, as you are only putting "rate of treatment initiation" onto the conveyor, but are also taking things off as well (rate of death 1, rate of ltfu 1, "rate of transfer (move) from 1"). I'd also expect to see "rate of transfer (move) into 1", "rate of treatment initiation" and "rate of treatment re-initiation" going onto the conveyor if this really was the correct thing to do.

So have a think about the real life process, is it a conveyor? If not, describe what actually happens. My guess is that "rate of progression to period 2" should be calculated differently, probably something like
rate of progression to period 2 = min ( Patients in period 1 of treatment / time step , Patients in period 1 of treatment / "average days of treatment (actual) 1*" ).
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
kalegria
Junior Member
Posts: 14
Joined: Tue Jan 24, 2017 12:49 pm
Vensim version: DSS

Re: Conveyor and limits in stocks

Post by kalegria »

I chose Conveyor following the example in Vensim I found.
I need patients to stay a minimum amount of days (ideal treatment duration 1, 2, 3) in each stock, before moving to the next (before the rate of progression can be applied). Is it not Conveyor how you get that effect? That is what the example "Population example with conveyors" in Vensim Help.
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Conveyor and limits in stocks

Post by tomfid »

I think part of the problem here is that the structure is more complex than what can be expressed with conveyors.

For example, if the outflow (rate of progression) from a stock uses DELAY CONVEYOR based on the inflow, that implies that the conveyor leakage is the only other process influencing the stock. However, you have deaths and multiple transfers. So, when it's time for a person to exit via the conveyor, it's possible that they've already moved elsewhere in the system by some other process. That's probably why the stocks go negative.

I think your best course would be to reformulate the model with first-order delay processes, like:

rate of progression = patients in treatment / average days in treatment

Then, once it's working, you can rethink the delay structures if the treatment delays are in fact fairly deterministic.
kalegria
Junior Member
Posts: 14
Joined: Tue Jan 24, 2017 12:49 pm
Vensim version: DSS

Re: Conveyor and limits in stocks

Post by kalegria »

Yes, the many outflows may be complicating the conveyor effects.
I have already tried the simple "rate of progression = patients in treatment / average days in treatment" approach. That is how I had it at first.

However, people moved too fast through the system. In reality, there is a minimum amount of days a patients must stay in each period, before moving to the next.

That is why I had to apply the conveyor. My problem was almost identical to that in the Vensim example. Is there another better/simpler way to implement this delay? One example would be: Patients remain in period 1 stock for 152 days before "rate of progression to period 2" pulls patient out?
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Conveyor and limits in stocks

Post by tomfid »

I see what you mean.

I think this approach could be made to work, with two changes:

- The inflow to the DELAY CONVEYOR needs to reflect all three inflows to the stock: initiation + transfer + re-initiation
- The leakage rate from the conveyor should reflect all three outflows: prob of LTFU + prob of transfer + prob of death

Another option would be to switch to an agent based approach, which would probably be easier in Ventity, but also possible in Vensim.
Post Reply