passing extra params to fmincon: anonymous function vs old method
이전 댓글 표시
Hi,
I was trying to pass extra parameters to fmincon function. I did it in two different ways: anonymous functions and old method, and I got 2 different results.
When I use anonymous functions, Matlab said that the initial point is already local minima. But when I use the old method, the optimization proceeds and run until the objective function x reaches f(x) = 0.0468.
Why is it like that? With this situation I prefer to use the old method to pass the extra parameters. However, the old method does not allow me add Output function to fmincon.
Thanks in advance. Amad
----------------
Anonymous function
Code:
myfun = @(k)funObj(kSearch,x0,ti,tP);
[kSearch,resnorm] = fmincon(myfun,kSearch,[],[],[],[],lb,ub,[],optionLSQ);
Output:
Max Line search Directional First-order
Iter F-count f(x) constraint steplength derivative optimality Procedure
0 51 0.0502957 0
Local minimum found that satisfies the constraints.
--------------------------
Old method:
Code:
[kSearch,resnorm] = fmincon(@funObj,kSearch,[],[],[],[],lb,ub,[],optionLSQ,x0,ti,tP);
Output:
Max Line search Directional First-order
Iter F-count f(x) constraint steplength derivative optimality Procedure
0 51 0.0502957 0
1 114 0.0502503 0 0.000244 -0.752 17.2
2 172 0.0495527 0 0.00781 -0.551 34.1
3 232 0.0494097 0 0.00195 -0.408 10.8
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Direct Search에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!