Function for reading from a vdf file

Use this forum to post Vensim related questions.
Post Reply
kaveh.dianati
Member
Posts: 33
Joined: Tue Dec 15, 2015 1:52 pm
Vensim version: DSS

Function for reading from a vdf file

Post by kaveh.dianati »

Dear Tom/Colleagues,

I was wondering whether there is a Vensim function for a variable to read values from inside a vdf file (e.g. a previous simulation).

The problem I need to solve is that in my model, I need to compare the values of a variable in various simulations against the values of the same variable in my baseline simulation. I am thinking whether I can define an additional variable which takes the values of my original variable in Baseline Simulation.vdf.

I hope my question is clear.

Many thanks.

Administrator
Super Administrator
Posts: 3522
Joined: Wed Mar 05, 2003 3:10 am

Re: Function for reading from a vdf file

Post by Administrator »

There is a GET_DATA_AT_TIME function, details on it are in the help system.

Does that do what you need?
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

tomfid
Administrator
Posts: 2937
Joined: Wed May 24, 2006 4:54 am

Re: Function for reading from a vdf file

Post by tomfid »

I think you want GET VDF DATA.

kaveh.dianati
Member
Posts: 33
Joined: Tue Dec 15, 2015 1:52 pm
Vensim version: DSS

Re: Function for reading from a vdf file

Post by kaveh.dianati »

Oh thanks. I didn't know about this function. It works beautifully!

tomfid
Administrator
Posts: 2937
Joined: Wed May 24, 2006 4:54 am

Re: Function for reading from a vdf file

Post by tomfid »

Great!

It's been a while since I've done this, but there's always a chicken-egg problem when the Base run that you're looking up comparison values from doesn't exist yet. I think I've solved this with some kind of IF THEN ELSE( base data = :NA:, 0, base data) logic, but I don't remember the details. Hopefully you've worked it out.

kaveh.dianati
Member
Posts: 33
Joined: Tue Dec 15, 2015 1:52 pm
Vensim version: DSS

Re: Function for reading from a vdf file

Post by kaveh.dianati »

I was just facing the exact same problem actually. Decided to delete that particular variable for my Base model, which leaves me with two model versions (not ideal). What you're suggesting is more elegant. I'm going to try and see if I can implement it now.

Thanks!!

tomfid
Administrator
Posts: 2937
Joined: Wed May 24, 2006 4:54 am

Re: Function for reading from a vdf file

Post by tomfid »

Another trick that I used ages ago, before GET VDF existed, was to create a separate model containing just a pair of variables that transform the base value into a data variable with a different name. Something like:

Main model:

price of cheese = {some simulated stuff}
data price of cheese {data variable, no equation}

Data model:

price of cheese {data variable, no equation}
data price of cheese := price of cheese

Then you do a run of the main model (base.vdf), and run the data model using base.vdf as input, to generate baseData.vdf. In subsequent runs of the main model, you load baseData.vdf which will populate the data variable.

The GET VDF solution is more elegant though.

Post Reply