查看单个帖子
旧 2019-11-25, 02:07   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
默认 Simplex method algorith partially working

I am trying to achieve the results from Table 8.6 (please see link). I am only able to reach the first few iterations.
I am following the pseudo code from table 8.5, but not successfully. Please have a look at the attempt and share suggestions.



https://rodolfoferro.wordpress.com/2017/02/24/nelder-mead-method/



My code attempt:



clc;
close all;
clear all;


B=[1.2 0];
G=[0 0.8];
W=[0 0];
M=[((B(1)+(G(1)))/2) (((B(2)+G(2))/2))];
R=2*M-W;


f= @(x) x(1)^2-4*x(1)+x(2)^2-x(2)-x(1)*x(2);




Points = sort([f(B),f(G),f(W)]);
fprintf('%d %d %d\n',Points)

for i=1:5
if f(R) < f(G)
if f(G) < f(B)
W=R;
Points = sort([f(B),f(G),f(W)]);
fprintf('%d %d %d\n',Points)



else
%R=2*M-W;
E=2*R-M;
if f(E) < f(B)
W=E;

Points = sort([f(B),f(G),f(W)]);
fprintf('%d %d %d\n',Points)


else
W=R;
Points = sort([f(B),f(G),f(W)]);
fprintf('%d %d %d\n',Points)




end
end
end


if f(R) < f(W)

W=R;
C = (W+M)/2;
Points = sort([f(B),f(G),f(W)]);
fprintf('%d %d %d\n',Points)
if f(C) < f(W)
W=C;
Points = sort([f(B),f(G),f(W)]);
fprintf('%d %d %d\n',Points)
else
S = (W+B)/2;
W=S;
G=M;
Points = sort([f(B),f(G),f(W)]);
fprintf('%d %d %d\n',Points)

end
end
end


I would like to be able to plot the simplex triangle animated as well.



Thanks much !!!!!





More answer...
poster 当前离线   回复时引用此帖