Hello all,
In searching I saw some topics that touched on this question, but haven't seen anyone address what I would consider to be the more basic issue: why is it possible, when the inflow to a stock is a (constant) rational number that is a fraction of 1, that the stock value can sometimes never equal 1?
For example-
inflow = 1/100
stock = inflow - outflow
outflow = IF THEN ELSE(stock = 1, stock, 0)
The outflow returns a value of 0 forever. It never pulls the value of "stock". To correct this issue I usually "cheat" and modify the outflow equation to read IF THEN ELSE(stock +.001 >= 1, stock, 0). I can understand why I may have to do this if the inflow were an irrational number... but it seems to me that cumulating 0.01 for 100 timesteps should result in a solid 1.00000000000000 ad inf.
Apologies if this has been discussed elsewhere, I may not have searched on the correct keyword. I am using DSS v6.1c if that info is relevant. Thank you -Buzz
basic vensim computation issue
-
- Super Administrator
- Posts: 4620
- Joined: Wed Mar 05, 2003 3:10 am
Re: basic vensim computation issue
What time step are you using in your model? And what is the value of the stock?
It may well be that there are rounding issues. Usually when emptying a stock, I'll use something like
It may well be that there are rounding issues. Usually when emptying a stock, I'll use something like
Code: Select all
outflow = IF THEN ELSE(stock >= 1, stock / time step , 0 )
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: basic vensim computation issue
I think the short answer is that 1/100 isn't precisely .01 in binary - it's 0.01000000000000000020816681711722. If you multiply 100*(1/100) the error is reversible, but if you sum 1/100 a hundred times, the error accumulates.
/*
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: basic vensim computation issue
Timestep = 1 (seconds), So .01 accrues to the stock every second.
thank you
Buzz
thank you
Buzz