Title says it all. I know this can be done by transformations by the user, but given that interval is so prominent in the ?doc and given that Nelder-Mead is the default method for optim(), it would be nice if the default method would honor this one, too. [could be done (even by me) within the R code because the C code through the arctan transforms]
Suggestion: Add box constraints to optim() default Nelder-Mead
3 messages · ivo welch, Ben Bolker, Martin Maechler
For what it's worth:
John Nash (original author of the Pascal implementations of (most of)
the available algorithms in optim() (including the Nelder-Mead)) has
long maintained that these implementations could be updated. (Any update
that changed solutions, rather than adding new functionality, would need
to be handled carefully for back-compatibility reasons ...)
Solving the problem of box constraints by transformation to an
unconstrained space is problematic when the constraints are binding
(i.e. the minimum is on the boundary of the allowed space) -- the
transformation essentially moves the solution to a point at infinity,
leading to infinite flatness ...
FWIW the Nelder-Mead implementation (?lme4::Nelder_Mead), and the
one in NLopt (accessible via the nloptr package:
https://nlopt.readthedocs.io/en/latest/NLopt_Algorithms/#local-derivative-free-optimization
) both allow box constraints. (The author of NLopt suggests that the
'subplex' algorithm is generally preferable ...) According to the CRAN
optimization task view
<https://cran.r-project.org/web/views/Optimization.html#general-purpose-continuous-solvers>,
the dfoptim package also has a box-constrained variant of Nelder-Mead ...
cheers
Ben Bolker
On 9/17/25 17:36, ivo welch wrote:
Title says it all. I know this can be done by transformations by the user, but given that interval is so prominent in the ?doc and given that Nelder-Mead is the default method for optim(), it would be nice if the default method would honor this one, too. [could be done (even by me) within the R code because the C code through the arctan transforms] [[alternative HTML version deleted]]
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
4 days later
Ben Bolker on Wed, 17 Sep 2025 19:00:00 -0400 writes:
> For what it's worth:
> John Nash (original author of the Pascal implementations of (most of)
> the available algorithms in optim() (including the Nelder-Mead)) has
> long maintained that these implementations could be updated. (Any update
> that changed solutions, rather than adding new functionality, would need
> to be handled carefully for back-compatibility reasons ...)
> Solving the problem of box constraints by transformation to an
> unconstrained space is problematic when the constraints are binding
> (i.e. the minimum is on the boundary of the allowed space) -- the
> transformation essentially moves the solution to a point at infinity,
> leading to infinite flatness ...
> FWIW the Nelder-Mead implementation (?lme4::Nelder_Mead), and the
> one in NLopt (accessible via the nloptr package:
> https://nlopt.readthedocs.io/en/latest/NLopt_Algorithms/#local-derivative-free-optimization
> ) both allow box constraints. (The author of NLopt suggests that the
> 'subplex' algorithm is generally preferable ...) According to the CRAN
> optimization task view
> <https://cran.r-project.org/web/views/Optimization.html#general-purpose-continuous-solvers>,
> the dfoptim package also has a box-constrained variant of Nelder-Mead ...
> cheers
> Ben Bolker
Just as this thread hasn't been continued,
and nobody mentioned -- hence for "completeness":
We (R-core, not me) had introduced a relatively simplistic but
useful constrOptim() function a long time ago, and it *does*
provide box constraints.
Hence, in some sense, Ivo Welch's wish has been fulfilled a long
time ago and *in base R* (the 'stats' package) :
E.g.
https://search.r-project.org/R/refmans/stats/html/constrOptim.html
Martin
> On 9/17/25 17:36, ivo welch wrote:
>> Title says it all.
>>
>> I know this can be done by transformations by the user, but given that
>> interval is so prominent in the ?doc and given that Nelder-Mead is the
>> default method for optim(), it would be nice if the default method would
>> honor this one, too.
>>
>> [could be done (even by me) within the R code because the C code through
>> the arctan transforms]
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel