-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Thanks for maintaining nloptr!
I've identified a bug where the Augmented Lagrangian does not return the most recent solution when encountering a roundoff error (status code -4). Instead it returns the initial condition.
The code below demonstrates that when BOBYQA is called outside of AUGLAG, it correctly returns the most recent solution before the roundoff error. When the same function is used inside AUGLAG, then it returns the correct status code (-4), but the wrong solution, defaulting to the initial condition.
library(nloptr)
optim_function <- function(x){
util <- log(x) + log(1e10-x)
return(-util)
}
optim <- nloptr(x0 = 3,
eval_f = optim_function,
lb = 1e-8,
ub = 1e10 - 1e-8,
opts = list(algorithm = "NLOPT_LN_BOBYQA",
xtol_abs = 1e-30,
xtol_rel = 0,
ftol_rel = 0,
ftol_abs = 1e-30,
maxeval = 100000))
optim_aug <- nloptr(x0 = 3,
eval_g_ineq = function(x){-x},
eval_f = optim_function,
lb = 1e-8,
ub = 1e10 - 1e-8,
opts = list(algorithm = "NLOPT_LN_AUGLAG",
xtol_abs = 1e-30,
xtol_rel = 0,
ftol_rel = 0,
ftol_abs = 1e-30,
maxeval = 100000,
local_opts = list(algorithm = "NLOPT_LN_BOBYQA",
xtol_abs = 1e-30,
xtol_rel = 0,
ftol_rel = 0,
ftol_abs = 1e-30,
maxeval = 100000)))
optim$status
optim$solution
optim_aug$status
optim_aug$solution
This returns
> optim$status
[1] -4
> optim$solution
[1] 202472257
> optim_aug$status
[1] -4
> optim_aug$solution
[1] 3
I am running
nloptr_2.0.3
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)
Metadata
Metadata
Assignees
Labels
No labels