# Choosing the Appropriate Algorithm and DT

Each of the simulation algorithms employed by the software has its own niche. The appropriate choice for an algorithm depends largely on the constructs that you employ in a given model. Similar considerations exist when you choose DT. Below, we provide a brief set of guidelines for choosing an appropriate simulation algorithm, and an appropriate step size (DT) for your simulation.

- If your model uses any of the software's discrete objects, or if you use Builtin functions to generate integer values (e.g., IF-THEN-ELSE logic to set 0-1 flags, INT, ROUND, SWITCH, etc.), use Euler's method. Runge-Kutta methods were designed to deal with continuously varying systems. As such, they do not deal well with queues, conveyors, and ovens. Nor do they deal well with integer values. Check to make sure that there are no discrete objects or Builtins that generate integer values in your model if you are using either of the Runge-Kutta methods.

- Use one of the Runge-Kutta methods if the system you're modeling is continuous and has inherent oscillatory tendencies. Because the integration error of Euler's method is cumulative, you will get specious results if you use Euler's method. A system that you know to be a sustained oscillator, for example, will always generate expanding oscillations if you're using Euler's method.

- Use a step size (DT) which achieves a good compromise between accuracy of results and speed of simulation. The smaller your simulation time step, the more accurate your simulation results. Unfortunately, the price of this accuracy is a long turnaround time for your simulation. Choosing a DT that achieves a good compromise may take a few trials. In general, a good first approximation would be to choose a step size one-half of the shortest time delay in your model. Many time delays may be apparent, such as average days payable, a shipping lead time, an oven cook time, or a training delay. If you can determine the shortest time delay, you've got a good starting point for selecting the step size.

- Always test your model for sensitivity to step size. Begin by running your model for the full length of a simulation. Plot and print some variables. Cut the step size in half and repeat the simulation. Compare the results from the two runs. Did the results change significantly? If they did, cut the step size in half and test again. Continue this process until the improvement in results becomes negligible.

More information about DT can be found in Chapter 12.