Hello,
I'd appreciate some advice on how best to pass data between Vensim models.
I have one model of a production process that ends with quantities of items in stock, their cost prices and so on. A second model will take the closing stock and price values from the first as its parameters for a sales drive. If I have both models in a common directory, can I write the closing values from the first model and use the 'GET DATA' function in the second to recover them? And can I set this to run automatically, so that the first model writes the data file when it reaches the end of the run?
Best wishes,
Phill
Passing data between models
Re: Passing data between models
Call this model A -> model B
If you create a data variable in model B with a name matching the output variable from model A, you can just load the run from A as an input dataset for B (see advanced tab of the sim control dialog). That way the var gets read extremely fast.
You can use GET DATA for more exotic purposes but it's slower and more work.
If you create a data variable in model B with a name matching the output variable from model A, you can just load the run from A as an input dataset for B (see advanced tab of the sim control dialog). That way the var gets read extremely fast.
You can use GET DATA for more exotic purposes but it's slower and more work.
/*
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
*/
Re: Passing data between models
Thank you for the advice, Tom. The two models will be running in classrooms and I really don't want the lecturers to have to perform any data management when switching from the first model to the second. Both models will run on a website, using the Vensim DLL on a server, so I think I can use the DLL to pass the output variables from model 1 as input variables for model two without the lecturers having to save and upload anything.
Re: Passing data between models
I'm not sure your users would need to do anything.
When you run model A, the generation of a dataset is automatic.
Similarly, when you run model B, it'll read the dataset specified on the Advanced tab without any intervention.
Two things could go wrong I guess:
- a file collision if there's a concurrent A write while B attempts to read
- if the user of A changes the run name
You could probably solve the second with a Pre/Post script.
When you run model A, the generation of a dataset is automatic.
Similarly, when you run model B, it'll read the dataset specified on the Advanced tab without any intervention.
Two things could go wrong I guess:
- a file collision if there's a concurrent A write while B attempts to read
- if the user of A changes the run name
You could probably solve the second with a Pre/Post script.
/*
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
*/
Re: Passing data between models
Thanks again for the advice. I can probably handle those potential problems in the web interface, by not allowing model B to run until model A is finished and, as you suggest, by using pre and post scripts.