Powell's Algorithm not obeying Upper Bound (UB)

Hello,
I am running Powell's algorithm with Golden Section method, to find the minimum of a function. My function call statement is as follows:
Q=pi/180;
S=Q*-8.5;
L=Q*-10;
U=Q*-8;
[xo,Ot,nS]=powell('My_Func',S,0,1,L,U,[],[],300);
My_Func is a user defined function. I am getting xo = -0.0727 as output, which is greater than U. Please explain why Powell's algorithm is not obeying boundaries.

5 Comments

@Debapriya Sengupta: Seriously? powell is no function of Matlab's toolboxes. There is no chance, that the readers cann guess, which code you run and if it contains bugs. We do not know the interface of this function also.
Please explain, which code you use.
Yes, I downloaded matlab code for Powell's algorithm from that link.
My_Func computes mutual information of two images A and B. The aim is to find the angle of rotation at which B should be rotated, so as to maximize the mutual information.
Please let me know if you require any other specific information about My_Func.
@Debapriya Sengupta: How can we solve the problem without having your code and data? We cannot debug the function provided by Giovani Tonel 15 years ago - but you can. Use the debugger to step through the code line by line.
I have already done a step run. I could not find a check for L or U anywhere in the code.

Sign in to comment.

Answers (1)

Jan
Jan on 19 May 2022
Edited: Jan on 19 May 2022
Yes, this is the documented behavior:
% Lb, Ub: lower and upper bound vectors to plot (default = x0*(1+/-2))
Lb and Ub are used for the graphics only.
Summary: You are using a function provided 15 years ago with a limited quality. It does not do, what you need and this is mentioned in the lean documentation. Then you explain in the forum, that this function does not do, what you need, but do not mention initially, which function you actually mean.
"Please explain why Powell's algorithm is not obeying boundaries."
Because this implementation of Powell's algorithm is not designed to consider the boundries for finding the result.
Sorry, you made it as hard as possible to find this trivial answer. You even found this answer by your own already: "I could not find a check for L or U anywhere in the code."

8 Comments

I am sorry for my lack of knowledge. I had expected a code downloaded from FileExchange to be as robust and versatile as all other inbuilt matlab codes. I did not pay attention to the "to plot" in the documentation.
Why would you expect code found on the file exchange, where anyone can post code, to be as robust asnd well written as code written by professionals in the field? Remember that anyone can post code to the FEX, including complete novices to programming. Trust that which you get for free to be sometimes worth what you paid for it. Admittedly, there are codes to be found on the FEX which were written by highly skilled coders who have written code as good as that which you will get from the MathWorks itself. But that is not the case for all such submissions.
Usually the comments can be good guides, but even there you can find false advertising. I could mention the case where someone used a fake account in the name of their own grandmother to post misleadingly admiring comments on their own useless code. So for any code you find, read the comments, but also look at the quality of the code you find. Good, well written code often has a look and feel that is very different from what would be posted by a novice. You will find clearly written help that explains the code and how to use it. You will find a well designed interface.
But in all cases, remember what you paid for free code.
@Debapriya Sengupta: Your questions about Matlab are welcome in the forum. It is the purpose of the forum to solve such problems.
You have overestimated the quality of the contributions to the FileExchange. And even for built-in functions written by MathWorks, reading the documentation carefully is important.
If you see, that a code does not do, what you want, trust your observation.
When you ask a question in the forum, provide as much relevant information as possible.
Now let's come to your actual problem: Do you need an implementation of the Powell algorithm with golden sction search and considering limits? Or would another optimzation tool solve your need also?
Specifically, I need an implementation of Powell's Direction Set algorithm with Brent's method for One-dimensional optimization.
Is it an option to write such a tool by your own?
Is there an alternate option available?
Torsten
Torsten on 20 May 2022
Edited: Torsten on 20 May 2022
The time when Powell's method became popular was FORTRAN time in software development. I guess you will find FORTRAN code for your problem in the internet.
Here is a link:

Sign in to comment.

Asked:

on 18 May 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!