使用 rank1 , BFGS 和 DFP 算法和准牛顿法在 powell 函数上获得相同的性能是否正常

问题描述

我正在尝试最小化鲍威尔函数 (x1+10x2)^2+5(x3-x4)^2+(x2-2x3)^4+10(x1-x4)^4 在 matlab 上使用拟牛顿法更新 通过秩一校正、DFP 算法和 BFGS 算法的 Hessian-inverse 近似。但在这 函数,我对每种方法都得到相同的结果。正常吗? 我的代码如下。

function [x_vals,fnc_vals] = quasi_newton(start_vec,termination,rank1,DFP1,BFGS1)
% the vector to be iterated is initialized to the initial guess.
x = start_vec;
% 2 matrices are initialized as matrices of zeros with very large
% sizes to avoid results exceeding the dimensions of the matrices.
% they will be used to store the vectors and the values of the function
% at each iteration.
% a variable to count number of iterations done when doing line search
% to determine the optimal step size is declared and initialized to 0.
vec= zeros(4,100000);
vals = zeros(1,100000);
% the initial hessian-inverse approximation is taken as the identity
% matrix.
H_k = eye(4);
grad = grad_eval_powell(x(1),x(2),x(3),x(4));
% a vector named grad is declared and initialized to the value of the gradient of
% the powell function at the point x. It will be changed in each
% iteration.
counter = 1;
% a counter is declared and initialized to 1.
while dot(grad,grad) > termination % when the termination criteria is not
  % satisfied.
  vec(:,counter) = vec(:,counter) + x; % the vector at the given iteration is 
  % stored in the corresponding index of the vec.
  vals(counter) = vals(counter) + eval_powell(x);
  % the value of the function at the given iteration is stored in the
  % corresponding index of vals.
  direction = -H_k*grad;
  % to optimize the step size,the golden section method is used.
  % for given iteration and vector,function bracketing is called
  % to determine the initial interval in which the optimal step size
  % value that makes the function value at the next iteration the
  % minimum.
  [a0,b0] = bracketing(@fi_gd,x,direction);
  % then by using the function golden_section,the minimizer
  % that makes the function value at the next iteration the
  % minimum is determined and stored in the alpha_k variable.
  alpha_k = golden_section(@fi_gd,a0,b0,direction);
  % the next point for the iteration to be done is determined
  % according to the quasi_newton method.
  x1 = x + alpha_k*direction;
  grad1 = grad_eval_powell(x1(1),x1(2),x1(3),x1(4));
  delta_x = x1-x;
  delta_grad = grad1-grad;
  % if statement below is satisfied when we want to use the rank-one
  % correction formula to determine U_k.
  if (rank1 && not(DFP1) && not(BFGS1))
      U_k = rank_one(delta_x,delta_grad,H_k);
  end
  % if statement below is satisfied when we want to use the DFP
  % algorithm to determine U_k.
  if (DFP1 && not(rank1) && not(BFGS1))
      U_k = DFP(delta_x,H_k);
  end
  % if statement below is satisfied when we want to use the BFGS
  % algorithm to determine U_k.
  if (BFGS1 && not(rank1) && not(DFP1))
      U_k = BFGS(delta_x,H_k);
  end
  % the approximation of hessian-inverse H_k is updated according to 
  % the quasi-Newton method.
  H_k = H_k + U_k;
  % the grad variable is assigned to be the grad1 for the next
  % iteration.
  grad = grad1;
  % the x variable is assigned to be the x1 for the next iteration.
  x = x1;
  % counter is iterated by +1 for storing the next iteration.
  counter = counter + 1;
end
vec = vec(:,1:counter-1); % the matrices vec and vals are shrinked to
% the size of the iterations.
vals = vals(1:counter-1);
% outputs are assigned by corresponding values.
x_vals = vec;
fnc_vals = vals;
end

哪里

function u_k = rank_one (delta_x,H)
% the vector parameter z is calculated according to the rank-one formula.
z = delta_x-H*delta_grad;
% the scalar parameter a is calculated according to the rank-one
% formula.
a = 1 / dot(z,delta_grad);
% the matrix u_k is calculated according to the rank-one formula.
u_k = a*(z*z');
end


function u_k = DFP (delta_x,H)
% the matrix u_k is calculated according to the DFP algorithm.
u_k = (delta_x*delta_x') / dot(delta_x,delta_grad) - ...
      ((H*delta_grad)*(H*delta_grad)') / dot(H*delta_grad,delta_grad) ;
end


function u_k = BFGS (delta_x,H)
% H*delta_grad and dot(delta_x,delta_grad) are assigned in Hg and xg
% respectively for the simplicity of the function that determines u_k.
Hg = H*delta_grad;
xg = dot(delta_x,delta_grad);
% u_k is calculated according to the BFGS algorithm.
u_k = (1 + dot(Hg,delta_grad)/xg)*((delta_x*delta_x')/xg) - ...
      (Hg*delta_x' + delta_x*Hg')/xg ;
end

能否请您至少在您的计算机上运行代码并告诉我您的结果? 我得到 0.0045,分 8 步计算。

顺便说一句,你可以使用

x = [3;-1;0;1];
term = 0.01;
[x1,y1] = quasi_newton (x,term,true,false,false);
[x2,y2] = quasi_newton (x,false);
[x3,y3] = quasi_newton (x,true);

以上代码为主要代码。

提前致谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)