资源简介
第一范数最小化matlab源代码,写的很详细,有注释,需要的可自行下载。
代码片段和文件信息
function [xstatushistory] = l1_ls(Avarargin)
%
% l1-Regularized Least Squares Problem Solver
%
% l1_ls solves problems of the following form:
%
% minimize ||A*x-y||^2 + lambda*sum|x_i|
%
% where A and y are problem data and x is variable (described below).
%
% CALLING SEQUENCES
% [xstatushistory] = l1_ls(Aylambda [tar_gap[quiet]])
% [xstatushistory] = l1_ls(AAtmnylambda [tar_gap[quiet]]))
%
% if A is a matrix either sequence can be used.
% if A is an object (with overloaded operators) At m n must be
% provided.
%
% INPUT
% A : mxn matrix; input data. columns correspond to features.
%
% At : nxm matrix; transpose of A.
% m : number of examples (rows) of A
% n : number of features (column)s of A
%
% y : m vector; outcome.
% lambda : positive scalar; regularization parameter
%
% tar_gap : relative target duality gap (default: 1e-3)
% quiet : boolean; suppress printing message when true (default: false)
%
% (advanced arguments)
% eta : scalar; parameter for PCG termination (default: 1e-3)
% pcgmaxi : scalar; number of maximum PCG iterations (default: 5000)
%
% OUTPUT
% x : n vector; classifier
% status : string; ‘Solved‘ or ‘Failed‘
%
% history : matrix of history data. columns represent (truncated) Newton
% iterations; rows represent the following:
% - 1st row) gap
% - 2nd row) primal objective
% - 3rd row) dual objective
% - 4th row) step size
% - 5th row) pcg iterations
% - 6th row) pcg status flag
% - 7th row) CPU time (added by Mario Figueiredo on 16/06/2007)
%
% USAGE EXAMPLES
% [xstatus] = l1_ls(Aylambda);
% [xstatus] = l1_ls(AAtmnylambda0.001);
%
% AUTHOR Kwangmoo Koh
% UPDATE Mar 4 2007
%
% COPYRIGHT 2007 Kwangmoo Koh Seung-Jean Kim and Stephen Boyd
%------------------------------------------------------------
% INITIALIZE
%------------------------------------------------------------
% IPM PARAMETERS
MU = 2; % updating parameter of t
MAX_NT_ITER = 400; % maximum IPM (Newton) iteration
% LINE SEARCH PARAMETERS
ALPHA = 0.01; % minimum fraction of decrease in the objective
BETA = 0.5; % stepsize decrease factor
MAX_LS_ITER = 100; % maximum backtracking line search iteration
% VARIABLE ARGUMENT HANDLING
% if the second argument is a matrix or an operator the calling sequence is
% l1_ls(AAtylambdamn [tar_gap[quiet]]))
% if the second argument is a vector the calling sequence is
% l1_ls(Aylambda [tar_gap[quiet]])
if ( (isobject(varargin{1}) || ~isvector(varargin{1})) && nargin >= 6)
At = varargin{1};
m = varargin{2};
n = varargin{3};
y = varargin{4};
lambda = varargin{5};
varargin = varargin(6:end);
elseif (nargin >= 3)
At = A‘;
[mn] = size(A);
y = vara
评论
共有 条评论