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.
- (1.15 MiB) Downloaded 24 times
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,
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.
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.
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?
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.
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.
Have a nice evening,