[d8e26d]: / MLFre / DPC / SLEP / pathSolutionTGL.m

Download this file

49 lines (41 with data), 1.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function [Sol,funVal,tsolver]=pathSolutionTGL(X, y, Lambda, opts)
%% solve the TGL problem for a sequence of parameter values
% -------------------------- pass parameters ---------------------------- %
npar = length(Lambda);
p=size(X,2);
tsolver = zeros(1,npar);
Sol = zeros(p,npar);
funVal = zeros(1,npar);
ind = opts.ind;
% ind1=[
% [1, 2, sqrt(2)]', [1, 3, sqrt(3)]'
% ]; % the higher layer
%
% ind2=[
% [1, 2, sqrt(2)]', [3,3,0]', [1, 3, sqrt(3)]'
% ]; % the higher layer
% -------------------------- compute lambda ----------------------------- %
lambda_max=findLambdaMax(X'*y, p, ind, size(ind,2));
if opts.rFlag == 1
Lambda = Lambda * lambda_max;
opts.rFlag = 0;
end
[Lambdav,Lambda_ind] = sort(Lambda,'descend');
% -------------------- solve the problems sequentially ------------------ %
for i = 1:npar
fprintf('in solver step: %d\n',i);
if opts.init~=2
if i == 1
opts.x0=zeros(p,1);
else
opts.x0=x1;
end
end
starts = tic;
%[x1, funVal1, ValueL1]= tree_LeastR(X, y, Lambdav(i), opts);
[x1, funVal1, ~]= tree_LeastR(X, y, Lambdav(i), opts);
tsolver(Lambda_ind(i)) = toc(starts);
funVal(Lambda_ind(i)) = funVal1(end);
Sol(:,Lambda_ind(i))=x1;
end
end