最优化函数fmincon的bug。
显示 更早的评论
这函数给定不同初始点可能求得不同的最优化解也就算了
但为什么解出的相同最优化解对应的目标函数值也不同???
贴上代码
%%%%定义目标函数test20150917%%%%%
function f=test20150917(h)
f=((h-3)^2-4)^2+(h-1)^2;
%%%%%%%%%%%%%%%%%%%%%
%%主函数初值给-1%%%%%
x0=[-1];
options=optimset('Display','off');
[h,f]=fmincon(@test20150917,x0,A,b,[],[],-2,7,[],options);
h
f
%%%%%%%结果%%%%%%%%
h = 1.0000
f = 7.4379e-10
%%主函数初值给-1%%%%%
x0=[3];
options=optimset('Display','off');
[h,f]=fmincon(@test20150917,x0,A,b,[],[],-2,7,[],options);
h
f
%%%%%%%结果%%%%%%%%
h = 1.0000
f = 4.2948e-13
奇葩的最优化
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 优化 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!