question

christian.n avatar image
3 Likes"
christian.n asked Adrian Haws edited

Speeding up a simulation model

We are having some problems with a model, and I was hoping someone could provide us with a couple of suggestions.

When we run the model, it executes at around 1 model minute per real time second, which is rather slow, considering that we aim to run the model for a one week production. We have tried cutting down on flow item transitions between fixed resources, and we have tried to minimize the amount of code executed for each flow item, but even so, it is slow going.

What are your experiences with modelling systems with massive amounts of flow items?

Are there any ‘low hanging fruits’ with regards to model optimization?

FlexSim 16.1.0
model speedrun timemodel optimizationexecution speed
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Logan Gold avatar image
7 Likes"
Logan Gold answered Logan Gold edited

If closing out of certain views does not speed up the model, then you can try using FlexScript Code Profiling to see which event(s) is taking the most real world seconds to execute. It will also tell you how many times an event is being executed during the model run. The FlexSim Code Profile window can be opened with the Debug menu:

After opening the code profiler, be sure to check the box for Enable FlexScript Code Profiling:

Then, run the model for as long as you want. As soon as the model is stopped, the FlexScript Code Profile window will populate with data. In the User Manual, you can find out what each field represents:

Self Time (ms) - This is the total amount of time in milliseconds that the code has taken to execute since the model began.

Total Time (ms) - This is the Self Time plus any time spent calling other functions like User Commands within the code.

Hit Count - This is the total number of times the code has been executed.

Path - The path to the flexscript node being executed.

This may give you an idea of where you can try optimizing the model.


5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Sam Stubbs avatar image
5 Likes"
Sam Stubbs answered Aditya Prakash commented

If performance is an issue, there is an old forum post that gives some good general advice about how to make the model move smoother and cleaner. You can find it here.

Especially look at the list of items Dustin Derrick posted, you can take a look at it and see if you can find anything on the list there that can help improve the model's performance.

If your model includes Global Tables, you may want to check out @Brandon Peterson's discussion regarding table access speed and the best ways to reference data in a Global Table here. Note that using bundles can be slightly faster than Global Tables, but may be extra work to convert your model.

· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Aditya Prakash avatar image Aditya Prakash commented ·

@Sam Stubbs, continuing in this thread regarding speed optimization of model. I want to know, do pt(), pf() functions cost even if my output console window is closed ? (I am aware that taking logs affects speed, but will closing the output console window suffice or I should comment all print statements ? )

0 Likes 0 ·
Brandon Peterson avatar image Brandon Peterson ♦ Aditya Prakash commented ·

Yes, they still have a cost but it is much (much, much) lower than it is with the output console open. I ran an experiment where I had a user command print a new line and the text "TEST" to the screen x times. The difference for 1,000 times was 1ms (closed) to 81.92ms (open). The difference for 100,000 times was 17ms (closed) to 8487ms (open).

So, it is roughly 500x faster when you have the output console closed. However, depending on the number of times you print to the output console you could start to see a speed hit even with the output console closed. Probably somewhere in the billions before it gets to a point where it would be worth the work to remove.

5 Likes 5 ·
Aditya Prakash avatar image Aditya Prakash Brandon Peterson ♦ commented ·
0 Likes 0 ·
Adrian Haws avatar image
2 Likes"
Adrian Haws answered

Hi Christian,

It sounds to me like you may be looking to make the model run more efficiently, with the large number of flowitems.

There are several ways to do this. The most effective are probably to close the 3D view as the model runs, as well as closing other windows such as dashboards, quick properties, library, etc.

This answer and this answer talk about this as well.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.