-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmax_con_bcd.m
43 lines (37 loc) · 946 Bytes
/
max_con_bcd.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
function [slack] = max_con_bcd(x,y,epsilon,x0)
kap = 2;
[m, n] = size(x);
A1 = zeros(2*m,n);
A1(1:2:end) = x;
A1(2:2:end) = -x;
b = zeros(2*m,1);
b(1:2:end) = y + epsilon;
b(2:2:end) = -y + epsilon;
%Initialization
if nargin>=4
if (length(x0)==9)
x0 = x0./x0(end);
x0 = x0(1:n);
end
para.x0 = x0;
s = max(reshape(A1*x0-b,kap,m)).';
para.s0 = max(s,0);
else
%--Obtain an initialization by the L1-RD
C = [b; zeros(m,1)];
B = [sparse(n,1); ones(m,1)];
J = kron(speye(m),ones(kap,1));
A = [A1, -J; sparse(m,n), -speye(m)];
K.l = size(A,1);
pars.eps = 1e-7;
pars.maxiter = 1e3;
pars.fid = 0;
[~,Y,~] = sedumi(A,-B,C,K,pars);
para.x0 = Y(1:n);
para.s0 = Y(n+1:end);
end
%-- Proximal BCD algorithm--
para.MAX_ITER = 5e3;
para.TOL = 1e-8;
para.rho=1;
[~,slack,~] = bcd_alg(A1,b,2,para);