1 Star 0 Fork 0

ZL/SSNLP

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
linesearch.m 2.49 KB
一键复制 编辑 原始数据 按行查看 历史
wenstone 提交于 2021-08-05 18:54 . Add files via upload
%%**********************************************************************
% This function do a simple linesearch along the direction d
% Input:
% z --- current iterate
% d --- the semi-smooth Newton direction
% t --- current penalty parameter of the augmented Lagrangian function
% A, b, c, l, u --- original data from the LP problem
% model --- struct inherited from ssn
% params --- struct inherited from ssn
%
% Output:
% stepsize --- the computed stepsize
% z_new --- z + stepsize * d
% x_new --- min(max(z_new, l), u)
% invAATtemp --- can be used later to compute F(z_new)
% ratio --- -(F(z_new)' * d) / norm(d)^2 / stepsize;
% model --- struct inherited from ssn
% ----------------------------------------------------------------------
% Author: Yiyang Liu, Zaiwen Wen
% Version 0.1 .... 2021/08
%%**********************************************************************
function [stepsize, z_new, x_new, invAATtemp, ratio, model] = linesearch(z, d, t, A, b, c, l, u, model, params)
stepsize = model.stepsize;
ATinvAATAz = A' * invAAT(A * z, model);
ATinvAATAd = A' * invAAT(A * d, model);
w = t * (c - model.ATinvAATAc) - model.ATinvAATb;
ATinvAATAw = -model.ATinvAATb;
%% first try stepsize from last ssn iteration
z_new = z + stepsize * d;
x_new = min(max(z_new, l), u);
min_normF = norm(x_new - (z_new - ATinvAATAz - stepsize * ATinvAATAd) - (w - 2 * ATinvAATAw));
%% then try other stepsizes
for alpha = [params.ssn_linesearch_ngrid - 1 : -1 : 1] * (1 / params.ssn_linesearch_ngrid)
ztemp = z + alpha * d;
xtemp = min(max(ztemp, l), u);
norm_Fztemp = norm(xtemp - (ztemp - ATinvAATAz - alpha * ATinvAATAd) - (w - 2 * ATinvAATAw));
if norm_Fztemp < min_normF
min_normF = norm_Fztemp;
stepsize = alpha;
elseif norm_Fztemp < model.normFz
break;
end
end
%%
z_new = z + stepsize * d;
x_new = min(max(z_new, l), u);
temp = A * (2 * x_new - z_new - t * c) - b;
invAATtemp = invAAT(temp, model);
model.Fz_new = A' * invAATtemp + z_new - x_new + t * c;
model.normFz_new = norm(model.Fz_new);
%% compute the ratio
ratio = -(model.Fz_new' * d) / norm(d)^2 / stepsize;
% equivalent (but more efficient) way to compute the ratio
% ratio = (d' * (x_new - z_new - w) - ATinvAATAd' * (2 * x_new - z_new)) / norm(d)^2 / stepsize;
end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zilinweiwei/SSNLP.git
git@gitee.com:zilinweiwei/SSNLP.git
zilinweiwei
SSNLP
SSNLP
main

搜索帮助