Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread John Fox
Hello Duncan, On 2024-12-13 5:30 p.m., Duncan Murdoch wrote: Caution: External email. On 2024-12-13 5:11 p.m., John Fox wrote: Dear Daniel, On 2024-12-13 2:51 p.m., Daniel Lobo wrote: Caution: External email. Looks like the solution 1.576708   6.456606   6.195305 -19.007996 is the best so

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Duncan Murdoch
On 2024-12-13 5:11 p.m., John Fox wrote: Dear Daniel, On 2024-12-13 2:51 p.m., Daniel Lobo wrote: Caution: External email. Looks like the solution 1.576708 6.456606 6.195305 -19.007996 is the best solution that nloptr can produce by increasing the iteration numbers. The better set of sol

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread John Fox
Dear Daniel, On 2024-12-13 2:51 p.m., Daniel Lobo wrote: Caution: External email. Looks like the solution 1.576708 6.456606 6.195305 -19.007996 is the best solution that nloptr can produce by increasing the iteration numbers. The better set of solution is obtained using pracma package.

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread J C Nash
On 2024-12-13 13:55, Daniel Lobo wrote: 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? As I indicated in a recent respo

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Ben Bolker
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' asserts that if we consider a broad enough class of optimization problems, *no* op

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Daniel Lobo
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

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread J C Nash
Interesting that alabama and nloptr both use auglag but alabama gets a lower objective fn. I think there could be lots of exploration of controls and settings to play with to find out what is going on. alabama::auglag f, ci, ce,ob,val: 0 -4.71486e-08 1029.77 1029.77 at [1] -0.610594

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Daniel Lobo
Looks like the solution 1.576708 6.456606 6.195305 -19.007996 is the best solution that nloptr can produce by increasing the iteration numbers. The better set of solution is obtained using pracma package. On Sat, 14 Dec 2024 at 01:14, John Fox wrote: > > Dear Daniel et al., > > Following on

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread John Fox
Dear Daniel et al., Following on Duncan's remark and examining the message produced by nloptr(), I simply tried increasing the maximum number of function evaluations: -- snip --- > nloptr(rep(0, 4), f, eval_g_ineq = hin, eval_g_eq = Hx, opts = + list("algorithm" = "NLOPT_LN_C

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread J C Nash
Setting penalty scales si, se at 1e+4 gets results somewhat near the alabama results. The problem seems quite sensitive to the constraint. JN Forwarded Message Subject: Re: [R] Non linear optimization with nloptr package fail to produce true optimal result Date: Fri, 13

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread J C Nash
The following may or may not be relevant, but definitely getting somewhat different results. As this was a quick and dirty try while having a snack, it may have bugs. # Lobo2412.R -- from R Help 20241213 #Original artificial data library(optimx) library(nloptr) library(alabama) set.seed(1) A

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Duncan Murdoch
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: libr

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Daniel Lobo
Thanks for your reply. I have checked the optimized value and applicable constraints. Both set of the values of parameters satisfy the constraints. What other solver would you suggest for this problem? On Fri, 13 Dec 2024 at 23:33, J C Nash wrote: > > COBYLA stands for Contrained Optimization b

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Daniel Lobo
Adding R help On Fri, 13 Dec 2024 at 23:39, Daniel Lobo wrote: > > If I use "algorithm" = "BOBYQA", the nloptr() fails with below message > > Error in is.nloptr(ret) : > > Incorrect algorithm supplied. Use one of the following: > > NLOPT_GN_DIRECT > > NLOPT_GN_DIRECT_L > > NLOPT_GN_DIRECT_L_RAN

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Ben Bolker
Fortune candidate? (Prof Zeileis, are you still collecting these?) Optimizers are like other tools. Some are chainsaws, others are scalpels. Don't do neurosurgery with a chainsaw unless you want a mess. __ R-help@r-project.org mailing list -- To

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Daniel Lobo
A small correction, the below combination 2.02, 6.764, 6.186, -20.095 Gives better result. On Fri, 13 Dec 2024 at 23:22, Daniel Lobo wrote: > > Hi, > > I have below non-linear constraint optimization problem > > #Original artificial data > > library(nloptr) > > set.seed(1) > A <- 1.34 > B <- 0.

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread J C Nash
COBYLA stands for Contrained Optimization by Linear Approximation. You seem to have some squares in your functions. Maybe BOBYQA would be a better choice, though it only does bounds, so you'd have to introduce a penalty, but then more of the optimx solvers would be available. With only 4 paramete

[R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Daniel Lobo
Hi, I have below non-linear constraint optimization problem #Original artificial data 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,