Steepest descents methods algoritme for higher dimensional objective functions

조회 수: 8 (최근 30일)
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
Clarisha
Clarisha 2024년 10월 21일
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 2024년 10월 21일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2024년 10월 21일
  댓글 수: 5
Clarisha
Clarisha 2024년 10월 22일
Thank you for the references. I just skipped the steepest descent method and used the fiminunc().
Matt J
Matt J 2024년 10월 23일
You're welcome, but please Accept-click the answer to indicate that it resolved your question.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2024년 10월 21일
fminsearch() uses simplex algorithm, not Steepest Descent.
  댓글 수: 2
Matt J
Matt J 2024년 10월 21일
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 2024년 10월 21일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by