Page 1 of 1

increasing model speed

Posted: Sat Aug 10, 2013 4:46 pm
by LAUJJL
Hi everybody

Joined two models that do the same job. The second one adding the flows through the vector to accelerate the computation. The difference is astounding.

One can notice too that the second one still is much quicker than the second one even in interpreted mode. One can notice too that compiling the first version does not add any speed, while compiling the second one adds speed.

It shows that sometimes it is worth considering restructure some models that are particularly long to simulate and replacing some common integrations by integrations through arrays.

Best regards.

JJ

Re: increasing model speed

Posted: Sun Aug 11, 2013 8:03 am
by schalkj
Thanks for the tip JJ. Great to learn something like this early in one's modelling career.

Regards
Schalk

Re: increasing model speed

Posted: Thu Aug 15, 2013 9:51 am
by LAUJJL
One must be aware that changing the integration process may come with a cost. Lots of functionalities in Vensim become unusable.
Suppose that the rate is stochastic and you want to smooth the level over a 10 days period. In the slow model you just have to use the smooth function, but with the accelerated model?

You are either obliged to build a rather tricky formula or to smooth only once every day instead of every time step. The fantastic acceleration may come with such an added complication that it becomes intractable. I think that Vensim people should think about the possibility to keep the advantage of the speed while still keeping the other functions available. That would be great.

I have started to restructure one of my models that is rather long to run (from 5 minutes to 15 minutes) to make it run about 20 times quicker. But the overhead generated is so high that I prefer to accept the low speed and have a simpler model to manage.

Best regards.

JJ

Re: increasing model speed

Posted: Fri Aug 16, 2013 3:21 pm
by tomfid
Hi JJ - Just to be sure I understand - are you comparing the speed of 1000 iterations of essai_vitesse to a single run of essai_vitesse2? - Tom

Re: increasing model speed

Posted: Fri Aug 16, 2013 9:41 pm
by LAUJJL
Hi Tom

My first models where a bit misleading, because they have not the same time horizon.

In fact there is only one run for each model. The results are the same, but they are not presented the same way.

I join the same models in mdl and vpm format for people having not the Vensim DSS, so they can run the model with the reader.

I have too added the calculation of the smoothing in both models and implemented the calculation in the accelerated model, to see if it is so more complicated.

I think that once one is used to this type of calculs it may not be so annoying.

I will try to implement this sort of acceleration in one of my model that is really long to run and see in practice the advantages and the drawbacks.

I have seen in the SD forum in the speed thread the reference to your optimizing propositions that i will study too.

I have other tricks to accelerate models, mainly by grouping variables to make it easier to erase the one's not useful in block in the text model.

I will explain the method in another message.

Regards.
JJ

Re: increasing model speed

Posted: Thu Dec 12, 2013 9:50 am
by LAUJJL
The solution is once that a model is finished to build an accelerated model equivalent to the slow one and to use it when speed matters.

regards.

JJ

Re: increasing model speed

Posted: Tue Dec 17, 2013 2:38 pm
by LAUJJL
Hi

Another solution to increase model’s speed is to define what I name the kernel of the model.

The kernel of a model is the part of the model that generates the behavior of the model, but no additional information that do not influence the behavior, nor any automatic imbedded tests.
One you have done that, one must give a group’s name to the kernel. If you want to accelerate the model, you must go to the text model and erase all the groups but the kernel and the control.

The result is a model that behaves the same than the original but that lacks tests and added information. You can always add what you are interested in to the kernel model or use the .vdf file as input to a model that will process the information generated by the kernel model for optimization for instance. See Tom Fiddaman’s advice. It is not possible to do that with the Synthesim.

To define the kernel, one must progressively erase all the supplementary variables until there are no more left. To do that I use SDMdoc that lists all the supplementary variables of a model.

Of course the added speed depends on how much added variables you erase go generate the kernel. It can be considerable and can triple the speed of a model.

This modification looks a bit like Tom Fiddaman’s advice about ‘getting rid of any extraneous structure’.

Regards.
JJ