fdaPDE/fdaPDE-R

`optimizer = "bfgs"` causes segfault in GCV lambda selection

AlePalu opened this issue · 0 comments

When using BFGS as optimization method, the R wrapper crashes with cause 'memory not mapped'

MWE

data("unit_square", package = "fdaPDE2")
unit_square <- Mesh(unit_square)
df <- ## some data...

model <- SRPDE(y ~ f, domain = unit_square, data = df)
## fit with BFGS optimization
model$fit(lambda = gcv(
    optimizer = "bfgs",
    lambda = 1e-4,
    step = 1e-6
))

The problem is releated to the R wrapper, as performing a BFGS optimization of the GCV from the C++ layer does not cause any segfault.

You can reproduce the test gcv_srpde_newton_test, laplacian_nonparametric_samplingatnodes_newton_fd_exact with BFGS in place of Netwon, and obtain the correct result using a wolfe line search approach for the adaptive step.

auto GCV = model.gcv<ExactEDF>();
GCV.set_step(4e-08);
// optimize GCV
BFGS<fdapde::Dynamic> opt(10, 0.05, 1);
DVector<double> pt = SVector<1>(6.25e-06);
opt.optimize(GCV, pt, WolfeLineSearch());