Optimization of the simulation speed

All topics specific to modeling questions in Enterprise Dynamics
Thore
Posts: 16
Joined: Sunday 28 October, 2018 - 13:27

Optimization of the simulation speed

Post by Thore »

Hi :)
I've developed a simulation model, which works as intended, but it takes long time to simulate. I guess much of the slow performance is due to my inexperience in modeling using ED, but maybe there is a couple of quickfixes that can rapidly decrease the simulation time. Do you have any genereal suggestions? Additionally, I've attched the model.

BR
Thore
Attachments
Combined_Neutral.mod
(1.15 MiB) Downloaded 204 times
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Optimization of the simulation speed

Post by HarryBunnik »

Ha Thore,

That what makes your model slower are the data recorders. You're writing every 24 hours several hundreds of lines into Excel. Unfortunately, such a connection is rather time-consuming and mostly used for smaller sets of data.

What you might want to try to do is to collect the data in the data recorder tables and at the end of your simulation run copy all into the ActiveX atom and then write all data at once into Excel, instead of having 60.000 separate writing calls. I would use an Event atom and create this copying event at hr(24) * 160 - 0.01. Then on the Excel ActiveX atom, you can use the write at a specific time (end of your simulation) to send all data to Excel. I think this will speed up your model to make it run 20-30 times faster.

I hope this helps you further,

Regards,

Harry
Thore
Posts: 16
Joined: Sunday 28 October, 2018 - 13:27

Re: Optimization of the simulation speed

Post by Thore »

Hi Harry
I've tested running the model without excel writing enabled, and it seems to run 20% faster, which is still a decent improvements. However, as we have touched upon before, in order to implement a solution like this I need some dynamic capabillities for what row (or column) to copy or write the data.

For instance, is there a way to change the Excel starting row of the ExcelActiveX atom? Similar to Att([StartRowExcel], ReDatarRcorder):= valCurrentRowInDataRecorder (in genereal where to get an overview of the different attribute names and the possibility for changing their value?)

Alternatively, is it possible to copy the data from the DataRecorder to a dynamic Row number in ExcelActive table? I've tried CopyTable but it does not provide this feature.

BR Thore
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Optimization of the simulation speed

Post by HarryBunnik »

Ha Thore,

I will have a look into this if I can find a way to make that working.

But first it surprisses me that your model "only" runs 20% faster when you turn off the Excel writing. At my computer a run with the Excel on takes me 7 minutes. Without (all data recorders turned off), its taking about 10 seconds.

So I'm wondering where the difference comes from.

Regards,

Harry
Thore
Posts: 16
Joined: Sunday 28 October, 2018 - 13:27

Re: Optimization of the simulation speed

Post by Thore »

7 minutes, for my model? :shock:
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Optimization of the simulation speed

Post by HarryBunnik »

Ok, how long is one single run taking for you?
Thore
Posts: 16
Joined: Sunday 28 October, 2018 - 13:27

Re: Optimization of the simulation speed

Post by Thore »

With 7 simualtion runs, of 160 days and warmup of 60 days, it takes around 4 hours.
My computer has 4 cores (can multi thread to 8) of i5-8250 1,6 Ghz. Maybe it is because it is only running on one core?
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Optimization of the simulation speed

Post by HarryBunnik »

Ok, that is quite a difference. Of course, I don't have your Excel file and am running with the data that is provided in the model and a self-made excel sheet to write the data away. Perhaps there is a difference.

My laptop is a relatively new i7 with 2.8 Ghz, so that will make some difference. Enterprise Dynamics is normally running on a single processor (so the frequency will make the difference here).

I'm also using Enterprise Dynamics 10.2, which also gives a small improvement.

As I said, I will see if I can speed it up by changing the export procedure. I hope that will bring something.
Thore
Posts: 16
Joined: Sunday 28 October, 2018 - 13:27

Re: Optimization of the simulation speed

Post by Thore »

Yes then I see the issue :/

Thanks for your help! it is really appreciated :)
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Optimization of the simulation speed

Post by HarryBunnik »

Ha Thore,

I've now built in that there is an Event atom which is triggered 2 seconds before the end of the simulation (hardcoded!) and copies the data to an extra ActiveX atom. (here also the row and columns are set. I found that it is placed in labels which I also have to update).

This ActiveX is set to copy the data to the excel file 1 second later.

This works now but is still not as fast as I would have liked. However, it seems to speed it up a bit. I will see if I have some new inspiration tomorrow.

Here is an adjusted model. Please check if all is still working as you have in mind and that I haven't accidentally messed something up.
Combined_Neutral HB.mod
(1.17 MiB) Downloaded 206 times
Have a nice evening,

Harry
Post Reply