0001
0002
0003
0004
0005 clear
0006 clear classes; close all;
0007
0008
0009
0010
0011
0012
0013 sim_runs = 10;
0014 tau_table = [.5, .1, .05, .01];
0015 outer_iterations = length(tau_table);
0016
0017 stack_time_solve = zeros(sim_runs*outer_iterations,4);
0018 stack_time_update = zeros(sim_runs*outer_iterations,3);
0019 stack_iter = zeros(sim_runs*outer_iterations,9);
0020
0021 for out_iter = 1:outer_iterations
0022 for sim_iter = 1:sim_runs
0023
0024 n = 1024;
0025
0026
0027 k = 512;
0028
0029
0030
0031 ratio_sp = 5;
0032 n_spikes = round(k/ratio_sp);
0033 T = n_spikes;
0034
0035
0036 x = zeros(n,1);
0037 q = randperm(n);
0038 x(q(1:n_spikes)) = sign(randn(n_spikes,1));
0039
0040
0041
0042 A = randn(k,n)/sqrt(k);
0043
0044
0045
0046
0047 sigma = 0.01;
0048 e = randn(k,1)*sigma;
0049 y = A*x + e;
0050
0051
0052 tau = tau_table(out_iter)*max(abs(A'*y));
0053
0054
0055
0056
0057
0058
0059 tic
0060 [xp, gamma_x, iter_xp, t_homotopy1] = BPDN_homotopy_function(A, y, tau,4*n);
0061 t_homotopy1 = toc;
0062 tolA_h = tau*sum(abs(xp))+1/2*(norm(A*xp-y))^2;
0063
0064
0065
0066 pdg_scale = 1e-6;
0067
0068 tolA = tolA_h+pdg_scale;
0069 stopCri=4;
0070 debias = 0;
0071 x_BB_mono = xp;
0072 t_BB_mono = 0;
0073 first_tau_factor = 0.8*(max(abs(A'*y))/tau);
0074 steps = 5;
0075
0076 tic;
0077 [x_BB_mono,x_debias_BB_mono,obj_BB_mono,...
0078 times_BB_mono,debias_start_BB_mono,mse]= ...
0079 GPSR_BB(y,A,tau,...
0080 'Debias',debias,...
0081 'Monotone',1,...
0082 'Initialization',0,...
0083 'Continuation',1,...
0084 'ContinuationSteps',steps,...
0085 'FirstTauFactor',first_tau_factor,...
0086 'StopCriterion',stopCri,...
0087 'Verbose', 0,...
0088 'True_x',xp,...
0089 'MaxiterA', 1000,...
0090 'ToleranceA',tolA,...
0091 'ToleranceD',0.001);
0092 t_BB_mono = toc;
0093
0094
0095 opts.mxitr = 4*n;
0096 opts.f_value_tol = tolA;
0097 M = [];
0098 tic
0099 [x_FPC, Out_FPC] = FPC_AS(n,A,y,tau,M,opts);
0100 t_FPC = toc;
0101
0102
0103 dx_model = 1;
0104 switch dx_model
0105 case 1
0106
0107 dx = zeros(n,1);
0108 T_in = randint(1,1,round(T/20));
0109 T_out = randint(1,1,round(T/20));
0110 qin = randperm(n);
0111 dx(qin(1:T_in)) = (randn(T_in,1));
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 dx(oldx_indices(qout(T_out+1:end))) = randn(T-T_out,1)*.1;
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('Nooooo');
0125 end
0126 xt = x+dx;
0127 yt = y+A*dx;
0128
0129 pk_old = A'*(A*xp-y);
0130 AtAgx = A(:,gamma_x)'*A(:,gamma_x);
0131 iAtAgx = inv(AtAgx);
0132
0133
0134 tic
0135 [xp_h, gamma_xh, iter_xp_update, t_homotopy_update2] = DynamicX_BPDN_function(A, AtAgx, iAtAgx, y, yt, xp, gamma_x, pk_old, tau,4*n);
0136 t_homotopy_update = toc;
0137 tolA_h = tau*sum(abs(xp_h))+1/2*(norm(A*xp_h-yt))^2;
0138
0139 tic
0140 [xp2, gamma_x2, iter_xp2, t_homotopy2] = BPDN_homotopy_function(A, y, tau,4*n);
0141 t_homotopy2 = toc;
0142
0143
0144
0145
0146
0147
0148
0149 tolA = tolA_h+pdg_scale;
0150 stopCri=4;
0151 debias = 0;
0152
0153
0154
0155 tic;
0156 [x_BB_mono_update,x_debias_BB_mono,obj_BB_mono,...
0157 times_BB_mono,debias_start_BB_mono,mse]= ...
0158 GPSR_BB(yt,A,tau,...
0159 'Debias',debias,...
0160 'Monotone',1,...
0161 'Initialization',x_BB_mono,...
0162 'StopCriterion',stopCri,...
0163 'ToleranceA',tolA,...
0164 'True_x',xp_h,...
0165 'MaxiterA', 1000,...
0166 'Verbose', 0,...
0167 'ToleranceD',0.001);
0168 t_BB_mono_update = toc;
0169
0170
0171 opts.x0 = x_FPC;
0172 opts.f_value_tol = tolA;
0173 M = [];
0174 tic
0175 [x_FPC_update, Out_FPC_update] = FPC_AS(n,A,yt,tau,M,opts);
0176 t_FPC_update = toc;
0177
0178 stack_time_solve((out_iter-1)*sim_runs+sim_iter,:) = [t_homotopy2 t_homotopy1 t_BB_mono t_FPC];
0179 stack_time_update((out_iter-1)*sim_runs+sim_iter,:) = [t_homotopy_update t_BB_mono_update t_FPC_update];
0180
0181 stack_iter((out_iter-1)*sim_runs+sim_iter,:) = [iter_xp2 iter_xp_update , length(times_BB_mono), (Out_FPC_update.nProdA+Out_FPC_update.nProdAt)/2 norm(xt-xp_h)/norm(xt) norm(xp_h-x_BB_mono_update)/norm(xp_h) norm(xp_h-x_FPC_update)/norm(xp_h) norm(xt-x_FPC_update)/norm(xt) Out_FPC_update.itr];
0182 [out_iter sim_iter]
0183 end
0184 end
0185
0186
0187 disp([' DynamicX BPDN homotopy GPSR FPC_AS']);
0188 table_stats = zeros(outer_iterations,8);
0189 table_stats(:,3) = mean(reshape(stack_iter(:,1),sim_runs,outer_iterations));
0190 table_stats(:,1) = mean(reshape(stack_iter(:,2),sim_runs,outer_iterations));
0191 table_stats(:,5) = mean(reshape(stack_iter(:,3),sim_runs,outer_iterations));
0192 table_stats(:,7) = mean(reshape(stack_iter(:,4),sim_runs,outer_iterations));
0193 table_stats(:,4) = mean(reshape(stack_time_solve(:,1),sim_runs,outer_iterations));
0194 table_stats(:,2) = mean(reshape(stack_time_update(:,1),sim_runs,outer_iterations));
0195 table_stats(:,6) = mean(reshape(stack_time_update(:,2),sim_runs,outer_iterations));
0196 table_stats(:,8) = mean(reshape(stack_time_update(:,3),sim_runs,outer_iterations))