write Projected Gradient project for rosenbrock function ?

1 commentaire

this my gradient Projection code :
function [x_k,fun_val]= projected_gradient_backtracking(f,g,x0,r,s,alpha,beta,epsilon)
x_k = x0;
grad = g(x_k);
fun_val = f(x_k);
iter = 0;
delta_x = 1;
while (delta_x > epsilon)
iter = iter+1;
t = s;
while f(x_k)-f(proj(x_k-t*grad)) < alpha*t*norm((1/t)*(x_k-proj(x_k-t*grad)))^2 %%% fix
t = beta*t;
end
x_kp1 = proj(x_k-t*grad);
delta_x = norm(x_k - x_kp1);
x_k = x_kp1;
fun_val = f(x_k);
grad = g(x_k);
fprintf('iter_number = %3d norm_grad = %2.6f fun_val = %2.6f \n',iter,delta_x,fun_val);
end
% subroutine
function xp = proj(y)
% Projection of the vector y on to the nonnegative orthant
%
% INPUT
% ======================
% y ........a column vector
% OUTPUT
% ======================
% xp .......the orthogonal projection of y onto the nonnegative orthant
xp = max(y,0);
end
end

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Oceanography and Hydrology dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by