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
290 stars 35 forks source link

LINCOA doesn't adhere to upper and lower bounds #178

Open asenzz opened 3 months ago

asenzz commented 3 months ago

I noticed running LINCOA will make it regularly underrun set lower bound for a parameter, and cause my program to stop. Is LINCOA supposed to be bounds checked? If not, can you add the feature of bounds for LINCOA?

zaikunzhang commented 3 months ago

Hi,

See https://github.com/libprima/prima/issues/42

In brief, this is known. It is not a bug. It is how Powell designed LINCOA and COBYLA. We optimization people call them "infeasible algorithms", which means that they are allowed to visit infeasible points, although they are supposed to achieve feasibility asymptotically. Such algorithms are common and non-strange.

Nevertheless, as mentioned in https://github.com/libprima/prima/issues/42, I do understand that bound constraints are often inviolable. Therefore, I plan to improve the algorithms to ensure they always respect bounds. However, I do not think I will have time for that within a few months.

cause my program to stop.

Which interface are you using? The MATLAB interface should be able to continue the optimization even if the evaluation of the objective/constraint function fails.

Thanks.

Zaikun

asenzz commented 3 months ago

My own, score, function crashes when the parameter is out of bounds. I would like to prevent that and used bounds checking inside the objective function but would prefer for it to be done by the algorithm itself - incorporate the given bounds in its calculation. The xl and xu options are not respected by LINCOA as I can see.

regards,

Zarko Asen

@.***

On Sat, Mar 23, 2024 at 5:43 PM Zaikun ZHANG @.***> wrote:

See #42 https://github.com/libprima/prima/issues/42

Which interface are you using? The MATLAB interface should be able to continue the optimization even if the evaluation of the objective/constraint function fails.

Thanks.

— Reply to this email directly, view it on GitHub https://github.com/libprima/prima/issues/178#issuecomment-2016543613, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACS4YPLKT6OMZAKQXXJPRQLYZWWLXAVCNFSM6AAAAABFEYNLFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWGU2DGNRRGM . You are receiving this because you authored the thread.Message ID: @.***>

zaikunzhang commented 3 months ago

I fully understand the situation. This is a known issue. Although this is not a bug, it will be fixed when I have time. See below (again).

In brief, this is known. It is not a bug. It is how Powell designed LINCOA and COBYLA. We optimization people call them "infeasible algorithms", which means that they are allowed to visit infeasible points, although they are supposed to achieve feasibility asymptotically. Such algorithms are common and non-strange.

Nevertheless, as mentioned in https://github.com/libprima/prima/issues/42, I do understand that bound constraints are often inviolable. Therefore, I plan to improve the algorithms to ensure they always respect bounds. However, I do not think I will have time for that within a few months.

In addition, may I know whether you are using LINCOA through any interface?

Which interface are you using? The MATLAB interface should be able to continue the optimization even if the evaluation of the objective/constraint function fails.

Thanks.

asenzz commented 3 months ago

That would be great, thanks. I use PrimaC - the C interface to the Fortran library in a multithreaded C++ project (G++ 13).

zaikunzhang commented 3 months ago

Thank you for the information.

mcmillab commented 2 weeks ago

I have the same problem. I use LINCOA in C# via CSNumerics.

Even for trivial X values, it seems to fail sometimes.

For example if I have these As and Bs:

LINCOAs: A and B are: 1 . . . 1
. 1 . . 1
. . 1 . 1
. . . 1 1
-1 . . . 1
. -1 . . 1
. . -1 . 1
. . . -1 1
1 1 1 1 .
-1 -1 -1 -1 .

it tells me "LINCOA has made the initial X feasible by increasing part(s) of B." when x=0,0,0,0 is a feasible solution. It then returns an infeasible solution.

Is there an easy fix here?

zaikunzhang commented 2 weeks ago

Hi @mcmillab ,

Thank you for your message. Could you provide a minimal working example?

I use LINCOA in C# via CSNumerics.

We don't provide PRIMA in C#. If it is not an interface provided by us, I am afraid that there is not much we can help with.

Thank you.

Zaikun

asenzz commented 2 weeks ago

Hi, Zaikun I found the bug yesterday, sorry for the delayed response and it was in my code, not in yours. I apologize for alarming you for no reason. I create a macro algorithm using your library that starts several optimizers in parallel at even parameter distances and selects the best ones at several points in time. This way I am able to boost the precision of the result by a significant amount (sacrificing computational resources). If you are interested I can contribute the code back to you so you will integrate it in Prima. I named it PPrima, stands for Parallel Prima, and it provides a C plus plus interface to Prima-C. Thanks for understanding, Žarko

regards,

Zarko Asen

@.***

On Mon, Jun 17, 2024 at 6:31 AM Zaikun ZHANG @.***> wrote:

Hi @mcmillab https://github.com/mcmillab ,

Thank you for your message. Could you provide a minimal working example?

I use LINCOA in C# via CSNumerics.

We don't provide PRIMA in C#. If it is not an interface provided by us, I am afraid that we will have little to do.

Thank you.

Zaikun

— Reply to this email directly, view it on GitHub https://github.com/libprima/prima/issues/178#issuecomment-2172216929, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACS4YPPVCXPTGHR4PCW2H5TZHZRCHAVCNFSM6AAAAABJNFZUHGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZSGIYTMOJSHE . You are receiving this because you authored the thread.Message ID: @.***>