---
title: "Building models that are efficient"
canonical: "https://modelassist.epixanalytics.com/space/EA/26575284/Building%20models%20that%20are%20efficient"
format: markdown
---
A model is most efficient when:

  


1. It takes the least time to run;
2. It takes the least effort to maintain;
3. It has a small file size;
4. It requires the least amount of assumptions; and
5. It supports the most decision options

### Least time to run

Crystal Ball is an add-in to Excel and, although it is well integrated into Excel, it will inevitably suffer somewhat in performance because of the interface. We'll look at a few hints for making Excel run faster, then making Crystal Ball run faster, and then making a model that gets the answer faster.

### Making Excel run faster

- Avoid array functions as they are slow to calculate, although faster than an equivalent [VBA](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575645) function;
- Use  [megaformulae](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575519/) (with caution) as they run about twice as fast as intermediary calculations, and ten times as fast as VBA calculations;
- Custom Excel functions run more slowly than built-in functions but speed up model building and model reliability;
- Avoid links to external files; and
- Keep the simulation model in one workbook.

### Making Crystal Ball run faster

- In the Run Preferences click on Speed dialog and select the following:
  - Minimize Excel during simulations
  - Suppress forecast window during simulations
  - Increase the burst mode by selecting Run, then Run Preferences, and then Speed. By default the Burst Model Option is on.
- Avoid using [Crystal Ball's Custom Distribution](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575279/) distribution with a large array if possible as they take much longer to generate values than other distributions;
- [Latin Hypercube sampling](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575293/) gets to the stable output quicker than [Monte Carlo sampling](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575292/)., but the effect gets quickly lost the more significant distributions there are in the model, particularly if the model is not just adding and/or subtracting distributions. The sampling methods take the same time to run, however, so it makes sense to use Latin Hypercube sampling for simulation runs;
- Avoid using [Crystal Ball's reporting functions](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575571/), unless absolutely necessary;
- <span style="color: #333333">Run </span><span style="color: #333333">[Bootstrap analyzes](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575339)</span><span style="color: #333333"> and </span><span style="color: #333333">[Bayesian distribution calculations](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575368)</span><span style="color: #333333"> in a separate spreadsheet when you are estimating uncorrelated parameters, fit the results using Crystal Ball's distribution fitting tool, and if the fit is good use just the fitted distributions in your simulation model. This does have the disadvantage, however, of being more laborious to maintain when more data become available.</span>
- Try to limit the use of other applications by either closing or minimizing them.
- Finally, if you really put a lot of value on simulation speed, you can either buy CB Turbo or increase your system's RAM.

### Smallest file size

- Megaformulae reduce the file size considerably;
- Using Crystal Ball reporting functions (as for example, using CB.GetForeStatFN( ) to automatically produce statistics after a simulation) will greatly increase the size of the model and slow it down;
- Maintaining large data sets in your model will increase the file size. Crystal Ball will also run slower. It is better to do the analysis outside the spreadsheet, and copy across the results;
- Sometimes large data sets or calculation arrays are used to construct distributions (e.g. fitting first or second order non-parametric distributions to data, constructing Bayesian posterior distributions, and Bootstrap analysis). Replacing these calculations with a fitted distribution can have a marked effect on model size and speed.

  


  


  


---