-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathssc_relaxed.m
64 lines (43 loc) · 979 Bytes
/
ssc_relaxed.m
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function [ Z ] = ssc_relaxed( X, lambda,W)
%% Solves the following
%
% min || X - XZ ||_F^2 + lambda || Z ||_1
%
% via ADM
%
% Created by Stephen Tierney
%
max_iterations = 500;
func_vals = zeros(max_iterations, 1);
n = size(X, 2);
Z = zeros(n);
J = zeros(n);
Y = zeros(n);
mu = 1;
tol_1 = 1*10^-2;
tol_2 = 1*10^-4;
lambda=lambda./abs(W);
lambda=lambda-diag(diag(lambda));
for k = 1 : max_iterations
Z_prev = Z;
J_prev = J;
% Solve for J
J = (X'*X + mu*speye(size(J))) \ (X'*X + mu*Z-mu*Y);
J = J - diag(diag(J));
J(J<0)=0;
% Solve for Z
V = J + Y;
Z = solve_l1(V, lambda ./ mu );
Z = Z - diag(diag(Z)); % make the diaginal element to zero
Z(Z<0)=0;
% Update Y
Y = Y + mu*(J-Z);
% Check convergence
%func_vals(k) = 0.5*norm(X - X*Z, 'fro')^2 + lambda*norm_l1(Z);
if (errorCoef(J,Z)<tol_2)
break;
end
end
disp(k)
end