kaskr / TMB_contrib_R

9 stars 6 forks source link

parallel computing in TMBhelper #16

Open fishecology7 opened 2 years ago

fishecology7 commented 2 years ago

Hi, I am trying to use the fit_tmb function in the TMBhelper package. The computation time of the following step was too long, and my computer still have extra cores which can be better used to save time. I have set the parallel computing environment on my computer, but didnot find the option to use it from parameters of the fit_tmb function. Any suggestions for this? and a case will be appreciated!

Opt = TMBhelper::fit_tmb( obj=Obj, lower = TmbList[["Lower"]], upper = TmbList[["Upper"]], getsd = TRUE, savedir = DateFile, bias.correct = TRUE, newtonsteps = 4, loopnum=3, getReportCovariance = TRUE, getJointPrecision = TRUE, bias.correct.control = list( sd = FALSE, split = NULL, nsplit = 1, vars_to_correct = "Index" ) )

Thank you so much!

Yunlong from YSFRI

Cole-Monnahan-NOAA commented 2 years ago

@fishecology7 newtonsteps=4, bias corrections, and getJointPrecision=TRUE will likely all add a lot of time. I suggest you pare back some of these arguments to simply optimizing and see if that is too slow. Then add each one back in to see what step of fitting is too slow.

Parallelization has to be done in the template as far as I know. See e.g., http://kaskr.github.io/adcomp/linreg_parallel_8cpp-example.html