Steepest descents methods algoritme for higher dimensional objective functions

6 views (last 30 days)
Hello,
I am trying to apply the steepest descent method on a function with 10 variables.
With 2 variables it is easy as I can split the problem. Now I tried to write this algoritme for a vector, but without succes.
In the following code you will first see a simple steepest descent algorithm and in the code below you see a similar algoritme based on a vector as input, especially needed to tackle higher dimensional problems, by using the vector notation in this algoritm.
Can I have some feedback.
Clarisha
clc
close
clear
%objective function
b=@(x,y) (1-x).^2+(y-x.^2).^2
%de gradient
dbdx=@(x,y) (2-4*x)-4*x*(y-x.^2)
dbdy=@(x,y) 2*(y-x.^2)
%initials
x0=20
y0=20
%proces
for i=1:10
s1=dbdx(x0,y0);
s2=dbdy(x0,y0);
xd=@(d) x0+d*s1;
yd=@(d) y0+d*s2;
bd=@(d) b(xd(d),yd(d));
d_star=fminsearch(bd,0)
x1=xd(d_star);
y1=yd(d_star) ;
iteratie=i
x0=x1%update initials
y0=y1%update initials
ObjectiveValue=b(x0,y0)
end
%********************************************************************************************************
%Steepest descent method for functions with more input.
B=@(X) (1-X).^2;
DBDX=@(X) -2*(1-X);
X0=[0 0]; %initials
for iteration=1:N
S=DBDX(X0);
XK=@(D) X0+D.*S;
BK=@(D) B(XK(D));
D_STAR=fminsearch(BK,X0);
X=XK(D_STAR)
X0=X
end
  3 Comments
Clarisha
Clarisha on 21 Oct 2024
Thank you for your quick response. I am actually trying to solve a PDE constraint problem with numerical methods. So I splitted the problem in two and one of the parts is optimizing an unconstrainted multidimensional function. As I am not so experienced in programming, I tried the steepest descent problem first. But what other methods would you suggest?
Clarisha
Clarisha on 21 Oct 2024
For your information I also tried the conjugate gradient method and a gmres code. And chose for the one I could best interprete in matlab.

Sign in to comment.

Accepted Answer

Matt J
Matt J on 21 Oct 2024
  5 Comments
Clarisha
Clarisha on 22 Oct 2024
Thank you for the references. I just skipped the steepest descent method and used the fiminunc().
Matt J
Matt J on 23 Oct 2024
You're welcome, but please Accept-click the answer to indicate that it resolved your question.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 21 Oct 2024
fminsearch() uses simplex algorithm, not Steepest Descent.
  2 Comments
Matt J
Matt J on 21 Oct 2024
But I think here fminsearch is being used to do the 1D line search step of steepest descent.
If so, it probably would have been better to use fminbnd.
Clarisha
Clarisha on 21 Oct 2024
Yes I read somewhere that the fminbind () is used for 1 dimensional problems. But infact I have a multivariate fcostunction with more than 30 dimensions (variables) and I am looking for the combination of these 30 variables that optimizes my costfunction.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!