Vensim Equation Auditing?

Use this forum to post Vensim related questions.
Post Reply
RobbieOrvis
Member
Posts: 43
Joined: Wed Dec 13, 2017 5:16 pm
Vensim version: DSS

Vensim Equation Auditing?

Post by RobbieOrvis »

We are building out some complicated new code and have noticed significant runtime slowdown (not surprising). We are wondering if there is any existing software or capability to audit the equations in a .mdl file and identify which are using the most memory/processing, in order to try and reduce the runtime. We are contemplating building something like this ourselves but also wanted to see if something already exists.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Vensim Equation Auditing?

Post by tomfid »

There isn't (but probably should be). Here's a trick I've used for this.

Run the model, and export the run to a .tab file with time across and subscripts in their own columns. Deselecting units keeps things simple.

Open the result in Excel. You can now count the output. Anything with a value in just the first column is a constant or INITIAL and therefore probably low cost.

For the rest, make a pivot table (you'll have to name the subscript columns r1, r2, etc. first), and add the count from the second or last column.
Then you can sort descending on the value. The variables with the highest dimensionality will be at the top.

This doesn't account for expensive functions (FIND ZERO and some of the ALLOCs) but it does capture the bulk complexity of the model.
Travis
Senior Member
Posts: 141
Joined: Tue Jul 15, 2008 8:42 pm

Re: Vensim Equation Auditing?

Post by Travis »

Robbie – this might not help you given how far along you are, but SDEverywhere includes performance measurement as part of its quality control tools. One way this has been used is to compare the performance of one version of the model with another. Sometimes this helps catch performance degradation as the model is being developed and the optimizations can be made right then and there.

The approach isn't as useful if there is a large atomic change in the model that I think you've done, but it is helpful for more incremental model changes.

If you want to open up a thread in the SDE GitHub, maybe there is a way to extend the performance tools in SDE to help reverse diagnose Vensim.

Also, since you're using SDE, I do recommend trying the new model version in SDE if you haven't already. SDE does some optimizations that Vensim doesn't, depending on what portions of the model is exposed in the web app.
RobbieOrvis
Member
Posts: 43
Joined: Wed Dec 13, 2017 5:16 pm
Vensim version: DSS

Re: Vensim Equation Auditing?

Post by RobbieOrvis »

Thanks @Tom. One other question for you. We have started using LOOKUP INVERT in some variables that have high dimensionality. Do you know if this is an expensive function? If not we can replace it with some math instead based on the input table we are using.

I'm looking into the output approach you mentioned now.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Vensim Equation Auditing?

Post by Administrator »

There is also this which might help.
https://metasd.com/2011/01/optimizing-vensim-models/

One of the common things I see is something like this.

proportion[company] = size[company] / sum ( size[company!] )

Much better to do something like

total company size = sum ( size[company!] )
proportion[company] = size[company] / total company size

When running the first equation, the sum is repeated for each company. The 2nd example, you calculate the sum once. If you have hundreds of companies, this can have a big impact on model speed.
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
RobbieOrvis
Member
Posts: 43
Joined: Wed Dec 13, 2017 5:16 pm
Vensim version: DSS

Re: Vensim Equation Auditing?

Post by RobbieOrvis »

Thanks that is helpful. We have an instance or two of that in the part of the codes that is heavily subscripted, and will edit accordingly.

Ultimately, we ended up just reducing the number of elements in a few of the main subscript ranges, which dramatically lowered the run time.
Post Reply