libprima / prima

PRIMA is a package for solving general nonlinear optimization problems without using derivatives. It provides the reference implementation for Powell's derivative-free optimization methods, i.e., COBYLA, UOBYQA, NEWUOA, BOBYQA, and LINCOA. PRIMA means Reference Implementation for Powell's methods with Modernization and Amelioration, P for Powell.
http://libprima.net
BSD 3-Clause "New" or "Revised" License
296 stars 38 forks source link

uobyqa: dynamically allocate pl #51

Closed jschueller closed 11 months ago

jschueller commented 12 months ago

allows to return an error instead of crashing when N is too large

jschueller commented 11 months ago

hi, what about this one @zaikunzhang ?

zaikunzhang commented 11 months ago

Hi @jschueller , I am a bit hesitating about this point. In this implementation, I try to keep things as straightforwrd as possible. To this end, I purposely used automatic arrays rather than allocatable ones whenever possible.

UOBYQA is not designed for problems with more than a few tens of variables. NEWUOA is designed for that. The current implementation of UOBYQA will not encounter any problem when the dimension is not more than 150 according to the stress test.

jschueller commented 11 months ago

I think we should make an exception for this one as its unusually big O(N^4), or another option is to cap N<150

zaikunzhang commented 11 months ago

I think we should make an exception for this one as its unusually big O(N^4), or another option is to cap N<150

OK. I agree with you. I have done it manually in https://github.com/libprima/prima/commit/a69d22dddb99d3c0dacccbb30b50758caa1f1dd3 , using safealloc, which is a wrapper of allocate with some checking. It will raise an error if the allocation fails.

If you think it is fine, I will close this. Thanks.

jschueller commented 11 months ago

fine with me

zaikunzhang commented 11 months ago

Thank you.