最优化函数fmincon的bug。
Afficher commentaires plus anciens
这函数给定不同初始点可能求得不同的最优化解也就算了
但为什么解出的相同最优化解对应的目标函数值也不同???
贴上代码
%%%%定义目标函数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
奇葩的最优化
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur 优化 dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!