new cpp file frogger_TMB.cpp for all the TMB related things. The reason I had to do this is because the frogger DLL was being created by Rcpp and it was registering only the routines we created and not TMB's. We need to create a separate DLL for TMB which doesn't use any Rcpp so that all the routines are exported. There is a way around this, and i know how to do it but Rich does not think it is a good idea, he's probably right about it. Basically involves us writing our own version of what RcppExports.cpp file looks like and adding the TMB routines into the CallEntries array (TMB exports all the routines it needs) so it would be a one line change to that file. But yh we would be the ones that have to manage that.
had to add a compile.R script that gets run via the Makevars (Makevars.win for windows systems), this code was taken from a package that uses TMB and is on CRAN, https://github.com/tsmodels/tsgarch/blob/main/src/TMB/compile.R, Makevars were similarly taken from that package too. This is seen in multiple packages so probably an established pattern of how to integrate Rcpp and TMB.
added a temporary test_tmb R function because it would be nice to actually keep checking that things actually work while we develop this.
added a simple test setup, parameters$incidinput was not a list for some reason, it is the only exception so i just made it a list, let me know if this is a problem or not equivalent. Currently TMB will just return a 0 and output some mgc stuff so if you want to print something from TMB function to test it out, use Rcout macro like so:
Rcout << model_variant;
it works like normal cout but for TMB. It will print 4 times though because the template is run 4 times
This resolves #70. Main points:
frogger_TMB.cpp
for all the TMB related things. The reason I had to do this is because thefrogger
DLL was being created by Rcpp and it was registering only the routines we created and not TMB's. We need to create a separate DLL for TMB which doesn't use any Rcpp so that all the routines are exported. There is a way around this, and i know how to do it but Rich does not think it is a good idea, he's probably right about it. Basically involves us writing our own version of what RcppExports.cpp file looks like and adding the TMB routines into theCallEntries
array (TMB exports all the routines it needs) so it would be a one line change to that file. But yh we would be the ones that have to manage that.compile.R
script that gets run via the Makevars (Makevars.win for windows systems), this code was taken from a package that uses TMB and is on CRAN, https://github.com/tsmodels/tsgarch/blob/main/src/TMB/compile.R, Makevars were similarly taken from that package too. This is seen in multiple packages so probably an established pattern of how to integrate Rcpp and TMB.test_tmb
R function because it would be nice to actually keep checking that things actually work while we develop this.parameters$incidinput
was not a list for some reason, it is the only exception so i just made it a list, let me know if this is a problem or not equivalent. Currently TMB will just return a 0 and output some mgc stuff so if you want to print something from TMB function to test it out, useRcout
macro like so:it works like normal
cout
but for TMB. It will print 4 times though because the template is run 4 times