Hello everyone,
I'm working on repeat a model using Vensim PLE 6.4b (32-bit) from a paper I read, but the model I create does not match the result in that paper. In brief, I need every stocks to be zero when they reached to the zero, since I cannot get negative number in this model. I've tried to use if else then statement like this:
IF THEN ELSE(Iraq Tanks >= 0,-Iraq Tanks Attrition Rate, Iraq Tanks=0),
and I set zero as the minimum for those stocks but it won't work.
Is there any way that I could ask Vensim to avoid getting negative numbers? Thank you!
Stop When Reaching to Zero
-
- Junior Member
- Posts: 2
- Joined: Fri Nov 18, 2016 5:14 pm
- Vensim version: PLE
Stop When Reaching to Zero
- Attachments
-
- Model_wo_Boundary_Graph.png (9.65 KiB) Viewed 8140 times
-
- Model_wo_Boundary.png (29.43 KiB) Viewed 8140 times
-
- Combat_Tanks_Helos.mdl
- (3.45 KiB) Downloaded 565 times
Re: Stop When Reaching to Zero
Generally the constraint to impose is:
Often min time to drain stock is equal to time step for convenience, so you can use the following shortcut:
Code: Select all
Stock = INTEG( inflow - outflow, init stock)
init stock = ...
inflow = ...
outflow = MIN( desired outflow, max outflow)
desired outflow = ...
max outflow = stock/min time to drain stock
Code: Select all
outflow = MIN(desired outflow, stock/TIME STEP)
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Junior Member
- Posts: 2
- Joined: Fri Nov 18, 2016 5:14 pm
- Vensim version: PLE
Re: Stop When Reaching to Zero
Thank you Tom. I searched the forum with some of the key words, but it did not give me what I wanted. However, the website in that post really helps!
Any way, I appreciate your reply!
Any way, I appreciate your reply!
tomfid wrote:Generally the constraint to impose is:
Often min time to drain stock is equal to time step for convenience, so you can use the following shortcut:Code: Select all
Stock = INTEG( inflow - outflow, init stock) init stock = ... inflow = ... outflow = MIN( desired outflow, max outflow) desired outflow = ... max outflow = stock/min time to drain stock
Code: Select all
outflow = MIN(desired outflow, stock/TIME STEP)
Re: Stop When Reaching to Zero
Another, perhaps simpler way to do this without adding in a new auxiliary variable (desired outflow) is to modify the equation for the stock from:
Stock = INTEG( inflow - outflow, init stock)
to
Stock = INTEG(max(inflow-outflow,-Stock/TIME STEP), init stock)
As light disadvantage to this is, in your diagram, you now you have an arrow going from TIME STEP directly to your Stock. This is a bit ugly and breaks the (my) rule of not having anything go into your Stock other than flows and initial values.
Stock = INTEG( inflow - outflow, init stock)
to
Stock = INTEG(max(inflow-outflow,-Stock/TIME STEP), init stock)
As light disadvantage to this is, in your diagram, you now you have an arrow going from TIME STEP directly to your Stock. This is a bit ugly and breaks the (my) rule of not having anything go into your Stock other than flows and initial values.
-
- Super Administrator
- Posts: 4827
- Joined: Wed Mar 05, 2003 3:10 am
Re: Stop When Reaching to Zero
I'd always advise against this approach. Keep things simple and clear, it means others can easily see what you are doing (and you can as well if you come back to the model after time away).daler6 wrote: ↑Thu Feb 06, 2020 6:57 pm Another, perhaps simpler way to do this without adding in a new auxiliary variable (desired outflow) is to modify the equation for the stock from:
Stock = INTEG( inflow - outflow, init stock)
to
Stock = INTEG(max(inflow-outflow,-Stock/TIME STEP), init stock)
As light disadvantage to this is, in your diagram, you now you have an arrow going from TIME STEP directly to your Stock. This is a bit ugly and breaks the (my) rule of not having anything go into your Stock other than flows and initial values.
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Stop When Reaching to Zero
An equally simple limit is:
outflow = MIN( desired outflow, stock/TIME STEP )
The assumption here is that the dynamics of the constraint are not of much interest, so that it's OK to assume that the minimum outflow time is equal to TIME STEP. This is usually fine.
This avoids having TIME STEP as an input to the stock on the diagram.
outflow = MIN( desired outflow, stock/TIME STEP )
The assumption here is that the dynamics of the constraint are not of much interest, so that it's OK to assume that the minimum outflow time is equal to TIME STEP. This is usually fine.
This avoids having TIME STEP as an input to the stock on the diagram.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Stop When Reaching to Zero
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Stop When Reaching to Zero
Thanks for the advice. I guess it is better to have TIME STEP as an input to the flow on the diagram.