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
increasing model speed
increasing model speed
 Attachments

 essai_vitesse2.mdl
 quicker model
 (1.88 KiB) Downloaded 154 times

 essai_vitesse.mdl
 slower model
 (1.34 KiB) Downloaded 151 times
Re: increasing model speed
Thanks for the tip JJ. Great to learn something like this early in one's modelling career.
Regards
Schalk
Regards
Schalk
Re: increasing model speed
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
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
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
/*
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: increasing model speed
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
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
 Attachments

 speedup.zip
 4 models in mdl and packaged format
 (130.56 KiB) Downloaded 127 times
Re: increasing model speed
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
regards.
JJ
Re: increasing model speed
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
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