Effacer les filtres
Effacer les filtres

How to define the step size of steepest-descent method and update the step size simultaneously in multiple variable function?

2 vues (au cours des 30 derniers jours)
How to define the step size of steepest descent method and update the step size simultaneously in multiple variable function? As following, the initial value of 2-dimensional object function are x0 and y0, but if i view { (x1’,y1’), (x2’,y2’) … (xn’,yn’) } as the initial value and i view f=[(x1-2)^2+(y1-4)^2]*[(x2-2)^2+(y2-4)^2]…[(xn-2)^2+(yn-4)^2] as the object function.how to apply steepest-descent method to f? (For (x1,y1) lamda1 is its step size,for (x2,y2) lamda1 is its step size,… for (xn,yn) lamda1 is its step size.)
% function [ R,n ] = steel(x0,y0,eps )
syms x;
syms y;
f=(x-2)^2+(y-4)^2;
v=[x,y];
j=jacobian(f,v);%计算梯度
T=[subs(j(1),x,x0),subs(j(2),y,y0)];
temp=sqrt((T(1))^2+(T(2))^2);
x1=x0;
y1=y0;
n=0;
syms kk;
while(temp>eps)
d=T;%计算下降方向
f1=x1+kk*d(1);
f2=y1+kk*d(2);
fT=[subs(j(1),x,f1),subs(j(2),y,f2)];
fun=sqrt((T(1))^2+(T(2))^2);
fun1=vpa(fun);
x0=x1-0.1*d(1);
y0=y1-0.1*d(2);
T=[subs(j(1),x,x0),subs(j(2),y,y0)];
temp=sqrt((T(1))^2+(T(2))^2);
temp1=vpa(temp);
x1=x0;
y1=y0;
n=n+1;
end
R=double([x0,y0]);
end

Réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by