It's a long way from "X works better than Y on this particular problem" to "X is superior to Y". It's a somewhat loose analogy, but the 'no free lunch theorem' <https://en.wikipedia.org/wiki/No_free_lunch_theorem> asserts that if we consider a broad enough class of optimization problems, *no* optimization algorithm is uniformly best ...
That answers question #2 ("no"). Answering question #1 requires a lot of work digging into the details of the problem, which I don't have the time & energy to do right now ... someone who knows a lot more about optimization *might* be able to answer based on previous experience and background knowledge, but even they might have to spend a lot of time digging ... On Fri, Dec 13, 2024 at 3:46 PM Daniel Lobo <danielobo9...@gmail.com> wrote: > > Hi Duncan, > > I take your advice. > > I posted here in search for a better answer to my problem as I could > not get that there. > > My question is: > 1. Why nloptr() is failing where other programs can continue with the > same set of data, numbers, and constraints? > 2. Is this enough ground to say that nloptr is inferior and user > should not use this in complex problems? > > I wish to get a thoughtful answer to above as my working environment > only has the nloptr package installed, and it is an isolated system > due to security issues and installation of a new package requires lot > lot of approvals and time consuming. > > BTW, if someone interested here is my original post > https://stackoverflow.com/a/79271318/15910619 > > On Sat, 14 Dec 2024 at 00:15, Duncan Murdoch <murdoch.dun...@gmail.com> wrote: > > > > You posted a version of this question on StackOverflow, and were given > > advice there that you ignored. > > > > nloptr() clearly indicates that it is quitting without reaching an > > optimum, but you are hiding that message. Don't do that. > > > > Duncan Murdoch > > > > On 2024-12-13 12:52 p.m., Daniel Lobo wrote: > > > library(nloptr) > > > > > > set.seed(1) > > > A <- 1.34 > > > B <- 0.5673 > > > C <- 6.356 > > > D <- -1.234 > > > x <- seq(0.5, 20, length.out = 500) > > > y <- A + B * x + C * x^2 + D * log(x) + runif(500, 0, 3) > > > > > > #Objective function > > > > > > X <- cbind(1, x, x^2, log(x)) > > > f <- function(theta) { > > > sum(abs(X %*% theta - y)) > > > } > > > > > > #Constraint > > > > > > eps <- 1e-4 > > > > > > hin <- function(theta) { > > > abs(sum(X %*% theta) - sum(y)) - 1e-3 + eps > > > } > > > > > > Hx <- function(theta) { > > > X[100, , drop = FALSE] %*% theta - (120 - eps) > > > } > > > > > > #Optimization with nloptr > > > > > > Sol = nloptr(rep(0, 4), f, eval_g_ineq = hin, eval_g_eq = Hx, opts = > > > list("algorithm" = "NLOPT_LN_COBYLA", "xtol_rel" = 1.0e-8))$solution > > > # -0.2186159 -0.5032066 6.4458823 -0.4125948 > > > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.