fminsearch giving results below initialisation point

조회 수: 1 (최근 30일)
udi ibgui
udi ibgui 2020년 1월 30일
댓글: John D'Errico 2020년 2월 6일
Hello,
I have a function that I am trying to minimise as follows
function x = kmean_per_dif_fit(img, adam)
x0 = [80,10,1];
tota = @(x)0;
totb = 0;
for i = 1:5
err = @(x)abs(round(sum(sum((abs(img{1} - x(1))<abs(img{1} - x(2))) == 1))/x(3))-adam(i));
tota = @(x)tota(x) + err(x);
totb = totb + adam(i);
end
a = @(x)tota(x)/totb;
x = fminsearch(a,x0)
end
As you can see, i have three unknowns and I try to initialise them at x0 = [80,10,1]
The answers that I get yet, are not within my initilastions
316.1776 -1.1811 2.6955
any help would be appreciated!
  댓글 수: 1
John D'Errico
John D'Errico 2020년 2월 6일
Very strange. (Not what fminsearch did, but what you are doing.)
You have one function in there called tota, which is identically zero. You add it to err(x). err is something strange looking too. But it appears that err is doing something highly non-differentiable, and certainly discontinuous.
Why is that a problem? Because fminsearch is not designed to solve such a problem.
And, of course, you do not tell us what img and adam are. IMG is some arbitrary cell array, containing only cell. adam is some unknown vector, of length 5. So we cannot even test your code out to show you what it does, and why fminsearch fails.
So it is totally impossible to help you, to explain why fminseach goes where it did go.
As for why it might have done so, fminseach has NO constraints upon it. So it can freely go wherever it decides might improve the objective function.

댓글을 달려면 로그인하십시오.

채택된 답변

Pravin Jagtap
Pravin Jagtap 2020년 2월 6일
Hello Udi,
I think this can happen because it depends on the function and starting point (Since 'fminseach' function uses heuristic method). The 'fminsearch' uses the Nelder-Mead simplex algorithm for getting the minimum value. Please refer to following documentation for more details on the algorithm.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by