stevengj / nlopt

library for nonlinear optimization, wrapping many algorithms for global and local, constrained or unconstrained, optimization
Other
1.84k stars 567 forks source link

The old implementation of COBYLA is buggy and challenging to maintain. Switch to the PRIMA implementation? #501

Open zaikunzhang opened 1 year ago

zaikunzhang commented 1 year ago

Dear NLopt maintainers,

This is Dr. Zaikun Zhang from the Hong Kong Polytechnic University. Together with Professor N.I.M. Gould, I am responsible for maintaining the derivative-free optimization solvers of late Professor M.J.D. Powell.

Thank you for making COBYLA and BOBYQA available in NLopt. I note that the current version is based on a C translation of the original Fortran 77 implementation, the latter being not maintained anymore.

Although Powell's Fortran 77 implementation is truly a masterpiece, it contains many bugs, most of which are due to the language itself. For example, see Section 4.4 of our recent paper and the GitHub issues / requests listed at the end of this message (not all of them concern NLopt).

To avoid the problems originating from the Fortran 77 code, I suggest you use the PRIMA implementation of Powell's solvers. PRIMA provides the reference implementation for Powell's renowned derivative-free optimization methods, namely COBYLA, UOBYQA, NEWUOA, BOBYQA, and LINCOA. The "P" in the name stands for Powell, and "RIMA" is an acronym for "Reference Implementation with Modernization and Amelioration".

PRIMA provides the modern implementation of the solvers in Fortran 2008. It fixes bugs in the original Fortran 77 code. In addition, it introduces improvements that boost the performance in terms of the number of function evaluations, which is the standard measure of computational costs in derivative-free optimization.

See the GitHub repo of PRIMA for more information. I will be glad to provide assistance if help is needed.

Thanks.


Issues and requests raised due to bugs in the Fortran 77 implementation (and translation) of Powell's solvers

stevengj commented 1 year ago

PRIMA sounds great! It's nice to have a modern implementation of these algorithms. It would mean adding a Fortran dependency to nlopt (at least an optional dependency), which is possible of course. There's also the question of integration with NLopt's stopping conditions (which in the case of other codes involved editing the source code) … PRIMA looks like a rather large codebase to integrate into NLopt directly (as opposed to simply linking to it if it is detected as being installed).

As a first step I would suggest trying to get conda packages of PRIMA available (and Yggdrasil for Julia). Even before that, you should set up a cmake script (or similar) to build your package ... it's not really a good idea to depend on Matlab to compile things.

Also, it's not obvious to me what kind of API you export; I don't see any API docs? If you want it to be easily callable from other languages you should ideally export a C interface (which is possible in modern Fortran via iso_c_binding) and a corresponding header file.

ararslan commented 11 months ago

As of v0.7, PRIMA is compiled with CMake, includes a C API, and has a builder in Yggdrasil.