How to get a surface plot for the given function to know how many minima are there?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a function whose code is given below. I want to determine whether it has one local minimum or several local minima? Fo this I want to see its surface plot But how? In this function, there are four decision variables namely A1, A2 ,Theta1 and Theta2. All are given in a row vector u. The range of A1 or A2 is from 0 to 10 and the range of Theta1 or Theta2 is from -90 to +90. How can I get its surface plot?
function e=myfun(b)% b is a rand vector of the same size as is u below
u=[2 7 50 85];% u=[A1 A2 Theta Theta2]
C=numel(b);
P=C/2;
M=2*C;
xo=zeros(1,M);
for k=1:M
for i=1:P
xo(1,k)=xo(1,k)+u(i)*exp(-1i*(k-1)*pi*cosd(u(P+i)));
end
end
xe=zeros(1,M);
for k=1:M
for i=1:P
xe(1,k)=xe(1,k)+b(i)*exp(-1i*(k-1)*pi*cosd(b(P+i)));
end
end
abc=0.0;
for m1=1:M
abc=abc+(abs(xo(1,m1)-xe(1,m1))).^2;
end
e=abc/M;
end
7 comentarios
Torsten
el 25 de Feb. de 2024
Editada: Torsten
el 25 de Feb. de 2024
But what is the role of -50 and -85 and emin-=0 here in the code which is displayed after execution?
theta1(imin) and theta2(jmin) are the mesh coordinates for theta1 and theta2 that give the minimum value of the objective function given that A1 = 2 and A2 = 7.
Further, if I keep different values of Theta1 and Theta2 in vector u, then the shape of the surface plot becomes different, why is it so?
Because u is part of the objective function:
xo(1,k)=xo(1,k)+u(i)*exp(-1i*(k-1)*pi*cosd(u(P+i)));
Changes in u lead to changes in e.
Additionally do the peaks and depths tell me about the maxima and minima within the given range i.e. -90 to 90?
Yes, assuming that A1 = 2 and A2 = 7.
Respuestas (1)
John D'Errico
el 24 de Feb. de 2024
Editada: John D'Errico
el 24 de Feb. de 2024
You cannot plot 4 independent variables. In fact, you would need 5 dimensions to plot, since you want to plot the result of that function for each of the 4 independent variables. But your monitor can display only 2 dimensions. Surface plots work as projections into the 2-d plane of the monitor, because your brain is wired to understand what it sees as a surface. Even then, your brain can be confused, and there are many optical illusions that prove this fact.
However, you cannot plot a 5 dimensional thing. It does not matter that you want to do so, or that your teacher told you to do so for 1 or 2 unknown variables. They apparently did not explain to you that this idea fails once you go beyond that point.
Wanting is not enough. Perhaps you have heard the old phrase, "If wishes were horses, beggars would ride"? That applies here. What works in a lower number of dimensions does not always extend to higher dimensions.
Is there anything you can do? In general, for some completely arbitrary nonlinear function one cannot know how many extrema there will be. If it is simple enough of course, then you may be able to derive a result mathematically. But there is no mathematical trickery you can employ that will always work for some fully general function.
One approach (often called multi-start) will be to start a nonlinear optimizer at very, many distinct start points. Allow it to operate until convergence for each start point. Then collect all of the results, and cluster all of the solutions, since you will get subtly different results even for the same extrema due to convergence tolerances. Count the number of substantially distinct solutions. That will be at least an approximation to the number of distinct solutions, unless you missed some due to insufficient start points in the multi-start.
The problem even with multi-start is that is is a computer hungry solution. a 4 dimensional search space can be pretty large, depending on how complex is your function. Not too bad usually in only 4-d, but I'm not going to spend the CPU time to see how complicated is your function.
9 comentarios
Ver también
Categorías
Más información sobre Global or Multiple Starting Point Search 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!