Hi,
Is it possible to extract a value at a specified time from a stock? For example, my stock has the following values:
Year 2000, stock = 0
Year 2001, stock = 1
Year 2002, stock = 2
Year 2003, stock = 3
...
Year 2029, stock = 29
Year 2030, stock = 30
Is there a straightforward way to extract a value, say the value for year 2015, and assign it to another variable in the same model? I know this can be done "manually", but want to see if it can be done "automatically". I tried "SAMPLE IF TRUE" however the result returned is a constant line for all years after 2015, rather than just 1 single value point for year 2015.
Many thanks.
Extract a value at a specified time from a stock
-
- Senior Member
- Posts: 105
- Joined: Wed Oct 25, 2017 3:52 pm
- Vensim version: PRO
Re: Extract a value at a specified time from a stock
You can't extract the 2015 value from a stock throughout the run, because that would be acausal.
SAMPLE IF TRUE works if you want the 2015 value at 2015 or later. You can initialize the SAMPLE to :NA: if you want to be able to detect whether the sampling has happened yet.
If you need the future value at the start of the run, the only option is to run iteratively. There's a GET VDF function that you can use to extract the value from a previous run, though I don't remember the details.
SAMPLE IF TRUE works if you want the 2015 value at 2015 or later. You can initialize the SAMPLE to :NA: if you want to be able to detect whether the sampling has happened yet.
If you need the future value at the start of the run, the only option is to run iteratively. There's a GET VDF function that you can use to extract the value from a previous run, though I don't remember the details.
/*
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
*/