GET DATA AT TIME

Use this forum to post Vensim related questions.
Post Reply
vukelic
Newbie
Posts: 1
Joined: Fri Oct 27, 2006 3:24 pm

GET DATA AT TIME

Post by vukelic »

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
Administrator
Super Administrator
Posts: 4841
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

"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.
claudia
Junior Member
Posts: 13
Joined: Tue Jul 06, 2010 6:55 pm

Post by claudia »

Did u resolve your problem? I need to do the same, choose a value of one variable at time=2 and keep it for the rest of the simulations. Can someone helps me? Thankx
tomfid
Administrator
Posts: 3995
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

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
claudia
Junior Member
Posts: 13
Joined: Tue Jul 06, 2010 6:55 pm

Post by claudia »

Very nice answer, I m very happy, it s appear functionning !
tomfid
Administrator
Posts: 3995
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

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
Post Reply