Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Speed up simulations

Jim Thorson edited this page Apr 6, 2019 · 6 revisions

How to speed up simulation experiments

People often comment "VAST is so slow, how can I conduct a simulation experiment comparing performance with other models?" It is definitely possible to conduct large, replicated simulation experiments involving VAST (I often do these studies, and others have independently as well), and I use this page to offer a few suggestions for how to speed up simulation experiments.

Tricks to speed up simulation experiments:

  1. Use more cores -- without any coding changes, you can always install and use Microsoft Open R (MRAN) instead of standard R. MRAN uses all cores available, and many desktops have 4 cores (resulting in 4-times faster models). People at AFSC can ask IT for a Virtual Machine (VM) with 10 cores, resulting in 10-times faster models.

  2. Start fixed effects at a good starting point -- VAST by default uses pretty uninformative starting values for fixed and random effects, and then estimation spends a good bit of time improving those. Many configurations of VAST (i.e., index standardization) are guaranteed to have a quadratic likelihood, so are guaranteed to get to the same MLE regardless of starting values. Therefore, a simulation experiment can be sped up by starting at better starting points using TMBhelper::Optimize( ..., startpar=XXX), where XXX is the true values, or values from a previous replicate, and this will not affect results except to save time.

  3. Turn off unnecessary stuff -- VAST is slowed down by using bias-correction, and can be sped up by using TMBhelper::Optimize( ..., bias.correct=FALSE). Similarly, some simulations don't require standard errors, and these can be turned off using TMBhelper::Optimize( ..., getsd=FALSE). Finally, turning off derived quantities by using Options = c("Calculate_Range"=FALSE, "Calculate_effective_area"=FALSE) is faster than when estimating derived quantities.

  4. Accept results with a higher final gradient -- example scripts for VAST typically are conservative about achieving convergence, and use TMBhelper::Optimize( ..., newtonsteps=1) to ensure that final gradients are typically < 1e-8. However, for simulations it might be sufficient to ensure that final gradients are below < 1e-3. This can be achieved by either manually running newtonsteps for chosen replicates, or setting newtonsteps=0.

  5. Reducing spatial resolution -- VAST can always be sped up by decreasing the spatial resolution, i.e., using a lower value for n_x.

Options 1-4 will typically not affect inference or scope for a simulation study, while decreasing spatial resolution (#4) will degrade VAST performance and therefore can affect results qualitatively. Finally, users can email a regional VAST POC for more suggestions.