SIMUL8 Tip – How to speed up your simulation
SIMUL8 has a really fast run time, which means that you can get the results you need quickly, but did you know that there are certain things you can do to speed up your simulation even more? These tips are particularly useful if you have a large model with lots of objects, because a few little tweaks could really make a difference.
Here are our top tips for speeding up your simulation
Has your Visual Logic been written in an efficient way? Use SIMUL8’s Speed Analyzer to find out the sections of your code that take the longest to run and improve them. You can access it from the Visual Logic Tab or by pressing Ctrl+Alt+S on your keyboard. Analysis is provided by assigning each block of Visual Logic code a percentage of total Visual Logic run time.
Avoid using Visual Logic Route-in Before Selecting
This section of Visual Logic is different from others as it doesn’t execute when a work item passes through and triggers it, but rather after every simulated event. This leads to an increase in the number of events and can therefore slow the simulation. So to speed up your simulation try to use in routing-in after loading as an alternative location for your visual logic.
No Routing Discipline Conflicts
Routing Discipline conflicts can slow down your simulation because SIMUL8 has to do more calculations to decide where the work item should go. To avoid this, make sure your simulation never has a priority routing-out object linking into a priority routing-in object. This can be corrected by placing a Queue between these items or changing one of the routing disciplines to passive.
If you are working with hundreds of thousands of work items that are essentially the same considered using High Volume. Maybe this could even be used for part of your system. This is useful for simulating many items with similar properties. All your work items are batched up and treated in bulk rather than individually so there are lots less events to process.
Results Synchronization Interval
You can change the Results Synchronization Interval using Preferences.
The default interval to collect results in SIMUL8 is every five time units. If you require greater accuracy this interval can be reduced, but to increase the speed of your model this interval can also be increased. In simulations that run over a long time period with many events, you can also increase this time interval to save memory, if this is an important factor to you.
Simulation Exit Objects
Information carried on work items often take up a lot of memory, particularly if you have many work items. By ensuring where possible that your simulation exit objects are specific End Points rather than Queues for example, this will ensure less memory is used recording finished work item’s label values.
Minimum Wait Time and Shelf Life
Storage bins making use of the Minimum Wait Time or Shelf Life features may also impact the speed that your simulation runs. This is due to SIMUL8 having to generate lots of events to keep checking on the status of the work item. You could use an Activity with replicate set to a high value and the cycle time to represent the wait time instead, then you only have one event per work item.
Only Use Match on Small Queues
The Match function in Routing In Collect in Activities tells SIMUL8 to search through the contents of a Queue to find 2 or more work items with identical label values. But if you use this option on long queues, say 50 work items or more, then it can slow down your simulation as SIMUL8 has to scan all the work items in the queue.
Simulation Objects that Collect Results
By default every simulation object in SIMUL8 collects results. Turn off results collection for objects you’re not interested in, for example dummy Activities added for routing purposes. This saves memory space on the PC and can allows simulations to run faster, reducing the execution time for each run.
Use Results All Dialog and highlight each object you want to switch results collection off (or on) then check or un-check the “Collect Results” check box. You can highlight one or many objects at the same time using Ctrl or Shift keys.
Be Clever With Spreadsheets
SIMUL8’s internal spreadsheets are really useful but when a vast amount of data is being written to them during the simulation run they can begin to slow down your simulation.
To help keep your simulation file size small when a spreadsheet is created it is very small. This means that as the spreadsheet grows, line by line, SIMUL8 has to expand the sheet. So as you write to a sheet it is dynamically expanded with each expansion requiring some processor time.
Store a 0 or blank (””) in the first cell of the row that you think the data will extend to. This will avoid the spreadsheet having to be extended with each new row of data and speed up your simulation. The file size will increase, but this should not matter except for save purposes.
Use ‘Else If’ statements
When writing Visual Logic often a string of ‘If’ statements can be replaced with ‘Else If’ statements speeding up the code execution time. SIMUL8 must test each ‘If’ statement to see if it is true. If ‘Else If’ statements are used then if SIMUL8 has found a previous condition to be true it does not have to test the subsequent ‘Else If’ statements. Below is a simple example where only 1 line less of code needs to be run. But if you have, for example, 20 ‘If’ statements the time saved is significant.
Do you think that any of these will help speed up your simulation?