Question about the fminsearch Algorithm
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hallo Community,
the documentation
states the following:
"fminsearch uses the Nelder-Mead simplex algorithm as described in Lagarias et al. [1]. This algorithm uses a simplex of n + 1 points for n-dimensional vectors x. The algorithm first makes a simplex around the initial guess x0 by adding 5% of each component x0(i) to x0. The algorithm uses these n vectors as elements of the simplex in addition to x0. (The algorithm uses 0.00025 as component i if x0(i) = 0.) Then, the algorithm modifies the simplex repeatedly according to the following procedure."
So now I wanted to know if I get this right:
Let's say my objective function looks like this
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1093205/image.jpeg)
So the simplex consists of 2+1 points. These 3 points are
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1093210/image.jpeg)
These 3 vectors make up the simplex, in this case the triangle.
So, first I wanted to know if my thoughts are correct?
If my description is correct, I wonder about two things:
1. Intuitively I would say that it would be more effective if the simplex is actually build AROUND x0. Because in this algorithm the simplex isn't really build around x0 but rather includes x0 to make up the simplex.
2. Is there a way for me to actually set up the starting simplex by myself? So that instead of giving the fminsearch-solver an initial guess x0, I create the starting simplex with the 3 Vectors
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1093215/image.jpeg)
and I get to choose how the components of the vectors look like.
0 comentarios
Respuestas (3)
Walter Roberson
el 10 de Ag. de 2022
"So, first I wanted to know if my thoughts are correct?"
Yes.
"Intuitively I would say that it would be more effective if the simplex is actually build AROUND x0."
Not really. If the surrounding points are higher than x0 then you will immediately project backwards.
The ability to provide coordinates for the initial simplex would matter most in the case that x0 is close to a constraint boundary, in which case you would need more details about what happens if the initial generated coordinates are outside of the boundary.
5 comentarios
Steven Lord
el 10 de Ag. de 2022
I've reported this to the staff responsible for the Service Request submission page for investigation.
Matt J
el 10 de Ag. de 2022
Editada: Matt J
el 10 de Ag. de 2022
Is there a way for me to actually set up the starting simplex by myself? So that instead of giving the fminsearch-solver an initial guess x0, I create the starting simplex with the 3 Vectors
You might be able to something approximately like this by formulating as a 6D problem:
objective=@(z) norm(z).^2;
FUN=@(x) min( [ objective(x(1:2)), objective(x(3:4)), objective(x(5:6))] );
initialSimplex=[0,0, 0,1, 1,0]-0.5
opts=optimset('Display','iter');
[x6,fval6]=fminsearch(FUN,initialSimplex,opts)
Is this better than formulating as a 2D problem? Not sure. We got to almost the same cost value in fewer iterations, each one less costly than the corresponding 6D iteration.
[x2,fval2]=fminsearch(objective,initialSimplex(1:2),opts)
0 comentarios
Bruno Luong
el 10 de Ag. de 2022
fminsearch is an mfile, you can copy it then mofify these lines #196 (R2022a)
% Set up a simplex near the initial guess.
% PUT HERE X == YOUR INITIAL GUESS #1
xin = x(:); % Force xin to be a column vector
v = zeros(n,n+1); fv = zeros(1,n+1);
v(:,1) = xin; % Place input guess in the simplex! (credit L.Pfeffer at Stanford)
x(:) = xin; % Change x to the form expected by funfcn
fv(:,1) = funfcn(x,varargin{:});
and #259 (R2022a)
% Continue setting up the initial simplex.
% Following improvement suggested by L.Pfeffer
at Stanford
usual_delta = 0.05; % 5 percent deltas for non-zero terms
zero_term_delta = 0.00025; % Even smaller delta for zero elements of x
for j = 1:n
y = xin;
if y(j) ~= 0
y(j) = (1 + usual_delta)*y(j);
else
y(j) = zero_term_delta;
end
% PUT HERE Y == YOUR INITIAL GUESS #2 3
v(:,j+1) = y;
x(:) = y; f = funfcn(x,varargin{:});
fv(1,j+1) = f;
end
0 comentarios
Ver también
Categorías
Más información sobre Nonlinear Control en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!