I have the Profesional version 5.5d.
I need to get some data at a specific time to make a choice that has to stay the same for the rest of the simulation.
I am trying to use GET DATA AT TIME but I is not working, even this simple example wouldn't work:
K1 = 10 + STEP(10,10)
K2 = GET DATA AT TIME(K1, 12)
I expect to get 20 but there are no values assigned to KK2 !?
Can you please tell me what I am doing wrong?
Thank you
GET DATA AT TIME
-
- Super Administrator
- Posts: 4841
- Joined: Wed Mar 05, 2003 3:10 am
"GET DATA AT TIME" will only work on data parameters (so they need to come from Excel, an external file etc).
If you only need the one value of K1 at time = 12, you can use
K2 = sample if true ( time = 12 , K1 , 0 )
You can also use some of the delay functions to get the value at the time you need.
Tony.
If you only need the one value of K1 at time = 12, you can use
K2 = sample if true ( time = 12 , K1 , 0 )
You can also use some of the delay functions to get the value at the time you need.
Tony.
Claudia -
If you just want to freeze the value after time 2, you can use the SAMPLE IF TRUE function.
One word of caution:
You can write SAMPLE IF TRUE( Time=2, myVar, myVar ) to capture the value of myVar at time 2. However, if there's roundoff error, or your time step is not a power of 2, this may fail because Time is never exactly 2. Thus it's better to use something like,
SAMPLE IF TRUE( PULSE( 2, TIME STEP), myVar, myVar ) - the pulse function takes care of the logic of making an event happen at time 2, accounting for roundoff etc.
Tom
If you just want to freeze the value after time 2, you can use the SAMPLE IF TRUE function.
One word of caution:
You can write SAMPLE IF TRUE( Time=2, myVar, myVar ) to capture the value of myVar at time 2. However, if there's roundoff error, or your time step is not a power of 2, this may fail because Time is never exactly 2. Thus it's better to use something like,
SAMPLE IF TRUE( PULSE( 2, TIME STEP), myVar, myVar ) - the pulse function takes care of the logic of making an event happen at time 2, accounting for roundoff etc.
Tom
/*
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
*/
Coming back to the original question, if k1 is really some kind of synthetic data (i.e. data created by a model equation that can't be handled as a data variable), one possibility is to move the calculation to a separate "data model". Then the output (.vdf) of the data model becomes the input to your main model as a data variable, and you can use GET DATA AT TIME or TIME SHIFT to look ahead into the data series.
Another possibility, if k1 is simple, is to parameterize things, as follows:
k1 = k1base + STEP(k1step, k1time)
k2 = k1base + STEP(k1step, k1time-horizon)
where horizon = 2 if you want to look 2 time units ahead into the expected value of k1.
This obviously doesn't work if you want to look ahead at the future value of an endogenous variable in a simulation. For that, there are also technical tricks, but generally you want to avoid such things, as we don't really know the future, so perfect foresight is a poor model of actual behavior.
Tom
Another possibility, if k1 is simple, is to parameterize things, as follows:
k1 = k1base + STEP(k1step, k1time)
k2 = k1base + STEP(k1step, k1time-horizon)
where horizon = 2 if you want to look 2 time units ahead into the expected value of k1.
This obviously doesn't work if you want to look ahead at the future value of an endogenous variable in a simulation. For that, there are also technical tricks, but generally you want to avoid such things, as we don't really know the future, so perfect foresight is a poor model of actual behavior.
Tom
/*
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
*/