0001
0002
0003
0004
0005 clear
0006
0007
0008
0009
0010
0011
0012
0013
0014 sim_runs = 100;
0015
0016 outer_iterations = 1;
0017
0018 stack_time_solve = zeros(sim_runs*outer_iterations,2);
0019 stack_time_update = zeros(sim_runs*outer_iterations,2);
0020 stack_iter = zeros(sim_runs*outer_iterations,5);
0021
0022
0023 FPC_problems = 2;
0024
0025 if FPC_problems == 1
0026
0027 Problist = {'Ameth6Xmeth2n1024m512k154seed200', 'Ameth6Xmeth6n1024m512k154seed200', ...
0028 'CaltechTest1', 'CaltechTest2', 'CaltechTest3', 'CaltechTest4'};
0029 di = 6;
0030 load( Problist{di}, 'b','Omega','n','xs');
0031
0032 m = length(b);
0033 x = xs;
0034 q = (find(abs(xs)>0));
0035 T = length(q);
0036 large_mag = max(abs(x(q)));
0037 small_mag = min(abs(x(q)));
0038 DCT_mat = dct(eye(n));
0039 A = DCT_mat(Omega,:);
0040 else
0041 n = 512;
0042 m = 228;
0043 T = 30;
0044 q = randperm(n);
0045 T1 = 15;
0046 T2 = T-T1;
0047 x = zeros(n,1);
0048 large_mag = 1e6;
0049 small_mag = 1e2;
0050 x(q(1:T1)) = randsrc(T1,1)*large_mag;
0051 x(q(T1+1:T1+T2)) = randsrc(T2,1)*small_mag;
0052
0053
0054 A = randn(m,n)/sqrt(m);
0055
0056
0057
0058 end
0059
0060
0061 sigma = 0.0;
0062 e = randn(m,1)*sigma;
0063 y = A*x + e;
0064
0065
0066 tau = .01*small_mag/large_mag*max(abs(A'*y));
0067
0068
0069
0070
0071
0072
0073
0074 tic
0075 [xp, gamma_x, iter_xp, t_homotopy1] = BPDN_homotopy_function(A, y, tau,4*n);
0076 t_homotopy1 = toc;
0077 tolA_h = tau*sum(abs(xp))+1/2*(norm(A*xp-y))^2;
0078
0079
0080
0081
0082
0083
0084 pdg_scale = 1e-3;
0085 opts.gtol = 1e-8;
0086
0087 tolA = tolA_h*(1+pdg_scale);
0088
0089 M = [];
0090 opts.f_value_tol = tolA;
0091
0092 tic
0093 [x_FPC, Out_FPC] = FPC_AS(n,A,y,tau,M,opts);
0094 t_FPC = toc
0095 [t_homotopy1 t_FPC]
0096
0097 for out_iter = 1:outer_iterations
0098 for sim_iter = 1:sim_runs
0099
0100
0101 dx_model = 1;
0102 switch dx_model
0103 case 1
0104
0105 dx = zeros(n,1);
0106 T_in = randint(1,1,round(T/10))+1;
0107 T_out = randint(1,1,round(T/10));
0108 new_large_small = round(rand(T_in,1));
0109 qin = randperm(n);
0110 dx(qin(1:T_in)) = randn(T_in,1).*(new_large_small.*large_mag + (1-new_large_small).*small_mag);
0111
0112 qout = randperm(T);
0113 oldx_indices = q(1:T);
0114 dx(oldx_indices(qout(1:T_out))) = -x(oldx_indices(qout(1:T_out))).*rand(T_out,1);
0115
0116 case 2;
0117
0118 oldx_indices = q(1:T);
0119 dx = zeros(n,1);
0120 dx(oldx_indices) = .1*randn(T,1);
0121 T_in = 0;
0122 T_out = 0;
0123 otherwise
0124 disp('DIY');
0125 end
0126 xt = x+dx;
0127 yt = y+A*dx;
0128
0129 pk_old = A'*(A*xp-y);
0130 pk_old(gamma_x) = sign(pk_old(gamma_x))*tau;
0131 AtAgx = A(:,gamma_x)'*A(:,gamma_x);
0132 iAtAgx = inv(AtAgx);
0133
0134
0135 tic;
0136 [xp_h, gamma_xh, iter_xp_update, t_homotopy_update] = DynamicX_BPDN_function(A, AtAgx, iAtAgx, y, yt, xp, gamma_x, pk_old, tau,2*n);
0137 t_homotopy_update = toc;
0138
0139 tolA_h = tau*sum(abs(xp_h))+1/2*(norm(A*xp_h-yt))^2;
0140
0141
0142 tic
0143 [xp2, gamma_x2, iter_xp2, t_homotopy2] = BPDN_homotopy_function(A, yt, tau,2*n);
0144 t_homotopy2 = toc;
0145 tolA_h = tau*sum(abs(xp))+1/2*(norm(A*xp-y))^2;
0146
0147
0148
0149
0150
0151
0152 tolA = tolA_h*(1+pdg_scale);
0153
0154 opts.x0 = x_FPC;
0155 opts.f_value_tol = tolA;
0156 M = [];
0157
0158 tic;
0159 [x_FPC_update, Out_FPC_update] = FPC_AS(n,A,yt,tau,M,opts);
0160 t_FPC_update = toc;
0161
0162 stack_time_solve((out_iter-1)*sim_runs+sim_iter,:) = [t_homotopy2 t_FPC];
0163 stack_time_update((out_iter-1)*sim_runs+sim_iter,:) = [t_homotopy_update t_FPC_update];
0164 stack_iter((out_iter-1)*sim_runs+sim_iter,:) = [iter_xp2 iter_xp_update (Out_FPC_update.nProdA+Out_FPC_update.nProdAt)/2 norm(xt-xp_h) norm(xt-x_FPC_update)];
0165 [out_iter sim_iter]
0166 end
0167 end
0168
0169
0170 disp([' DynamicX BPDN homotopy FPC_AS']);
0171 disp([' nProdAtA CPU nProdAtA CPU nProdAtA CPU'])
0172 table_stats = zeros(length(outer_iterations),6);
0173 table_stats(:,3) = mean(reshape(stack_iter(:,1),sim_runs,outer_iterations));
0174 table_stats(:,1) = mean(reshape(stack_iter(:,2),sim_runs,outer_iterations));
0175 table_stats(:,5) = mean(reshape(stack_iter(:,3),sim_runs,outer_iterations));
0176 table_stats(:,4) = mean(reshape(stack_time_solve(:,1),sim_runs,outer_iterations));
0177 table_stats(:,2) = mean(reshape(stack_time_update(:,1),sim_runs,outer_iterations));
0178 table_stats(:,6) = mean(reshape(stack_time_update(:,2),sim_runs,outer_iterations));
0179 table_stats