⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 steepest_descent.m

📁 压缩包里包含了无约束优化问题常用的几种求解方法的源程序:变量轮换法(variable_rotation.m)、最速下降法(steepest_descent.m)、修正牛顿法(modified_newt
💻 M
字号:
function [min,solvec,stepnum]=steepest_descent(str,ini,err)
%  File name:steepest_descent.m      
%  Author:Yan Anxin
%  ID number:081810
%  Date:finished on 2008.11.16
%  Description:  
%       Here defines a function,to solve the bivariate unconstrained optimization problems by steepest-descent-method
%       In the syntax [min,solvec,stepnum]=steepest_descent(str,ini,err),
%       str----input,means the expression of objective function
%       ini----input,sets the starting point to ini 
%       err----input,sets admissible error
%       min=steepest_descent(str,ini,err) attempts to find min, i.e. the minimum of objective function   
%       [min,solvec]=steepest_descent(str,ini,err) returns solvec, i.e. the minimum point  
%       [min,solvec,stepnum]=steepest_descent(str,ini,err) returns stepnum, i.e. the times of iterative       

k=1;stepnum=0;
[A,b]=coefficient_matrix(str);           %calls the function coefficient_matrix(str) to obtain the coefficient
x(:,1)=ini;
syms x1 x2
while norm(gradient(str,x(:,k)))>=err    %calls the function gradient(str,x) to obtain the gradient
    p=-gradient(str,x(:,k));
    H=2*A;
    lambda(k)=p'*p/(p'*H*p);
    x(:,k+1)=x(:,k)+lambda(k)*p;
    k=k+1;stepnum=stepnum+1;
end
solvec=x(:,k);
min=minval(str,solvec);                  %calls the function minval(str,solvec) to obtain the minimum value

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -