Passing data between models

Use this forum to post Vensim related questions.
Post Reply
Phill
Senior Member
Posts: 156
Joined: Wed Jun 04, 2014 2:18 pm
Vensim version: DSS

Passing data between models

Post by Phill »

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
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Passing data between models

Post by tomfid »

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.
Phill
Senior Member
Posts: 156
Joined: Wed Jun 04, 2014 2:18 pm
Vensim version: DSS

Re: Passing data between models

Post by Phill »

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.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Passing data between models

Post by tomfid »

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.
Phill
Senior Member
Posts: 156
Joined: Wed Jun 04, 2014 2:18 pm
Vensim version: DSS

Re: Passing data between models

Post by Phill »

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