search for: objective_function

Displaying 1 result from an estimated 1 matches for "objective_function".

2020 Oct 15
0
calling stats::optim from Rcpp causes memory leak
...mory (very little, but it compounds if it's a part of repeatedly running simulation). I created a minimal reproducible example, but I have no idea where does the leak originate. Could I ask for guidance on dealing with this issue? Rcpp code: #include <Rcpp.h> using namespace Rcpp; double objective_function(double x){ double obj = .666 - x; return pow(obj, 2); } // [[Rcpp::export(leak)]] double leak(double a, double b){ // Extract R's optim function Rcpp::Environment stats("package:stats"); Rcpp::Function optim = stats["optim"]; // Call the optim function from R...