What is the question being asked?
How to code adaptive Wolfe Powell Code....?
1 次查看(过去 30 天)
显示 更早的评论
function [alpha, k] = calc_alpha(fun,fun_grad, xk, dk, rho, sigma)
Alpha=[];
alpha_low = 0;
alpha_high = 10;
alpha = 1;
k = 0;
stop = 0;
while stop == 0
k=k+ 1;
if fun(xk + alpha * dk) <= fun(xk) + rho * alpha *fun_grad(xk)'* dk && (fun_grad(xk + alpha * dk))'* dk >= (sigma*fun_grad(xk))'* dk
stop = 1;
else
if fun(xk + alpha * dk) > fun(xk) + rho * alpha *abs(fun_grad(xk))'* dk
alpha_high = alpha;
alpha = (alpha_high+alpha_low) / 2;
elseif (fun_grad(xk + alpha * dk))'* dk < (sigma*fun_grad(xk))'* dk
alpha_low = alpha;
if alpha_high > 10
alpha = 2 * alpha_low;
else
alpha = (alpha_high + alpha_low) / 2;
end
end
end
Alpha =[Alpha, alpha];
end
回答(0 个)
另请参阅
类别
在 Help Center 和 File 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!