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.
Function for reading from a vdf file
-
- Senior Member
- Posts: 50
- Joined: Tue Dec 15, 2015 1:52 pm
- Vensim version: DSS
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Function for reading from a vdf file
There is a GET_DATA_AT_TIME function, details on it are in the help system.
Does that do what you need?
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Function for reading from a vdf file
I think you want GET VDF DATA.
/*
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
*/
-
- Senior Member
- Posts: 50
- Joined: Tue Dec 15, 2015 1:52 pm
- Vensim version: DSS
Re: Function for reading from a vdf file
Oh thanks. I didn't know about this function. It works beautifully!
Re: Function for reading from a vdf file
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.
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.
/*
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
*/
-
- Senior Member
- Posts: 50
- Joined: Tue Dec 15, 2015 1:52 pm
- Vensim version: DSS
Re: Function for reading from a vdf file
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!!
Thanks!!
Re: Function for reading from a vdf file
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.
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.
/*
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
*/