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...