Mercurial > hg > smallbox
comparison toolboxes/alps/ALPSdemo.m @ 154:0de08f68256b ivand_dev
ALPS toolbox - Algebraic Pursuit added to smallbox
author | Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk> |
---|---|
date | Fri, 12 Aug 2011 11:17:47 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
153:af307f247ac7 | 154:0de08f68256b |
---|---|
1 % ========================================================================= | |
2 % Algebraic Pursuit algorithms - Demo | |
3 % ========================================================================= | |
4 % Algebraic Pursuit (ALPS) algorithms are accelerated hard thresholding methods | |
5 % on sparse recovery of linear inverse systems. In particular, let | |
6 % Phi : M x N real matrix (M < N) | |
7 % x* : N x 1 K-sparse data vector | |
8 % n : N x 1 additive noise vector | |
9 % then, y = Phi x* + n is the undersampled M x 1 measurement vector. ALPS | |
10 % solve the following minimization problem | |
11 % minimize ||y - Phi x||^2 subject to x is K-sparse vector. | |
12 % | |
13 % Detailed discussion on the algorithm can be found in | |
14 % [1] "On Accelerated Hard Thresholding Methods for Sparse Approximation", written | |
15 % by Volkan Cevher, Technical Report, 2011. | |
16 % ========================================================================= | |
17 % 01/04/2011, by Anastasios Kyrillidis. anastasios.kyrillidis@epfl.ch, EPFL. | |
18 % ========================================================================= | |
19 | |
20 clear all | |
21 close all | |
22 clc | |
23 | |
24 addpath ALPS/; | |
25 | |
26 % General parameters | |
27 N = 1000; % Size of sparse vector x | |
28 M = 300; % Number of measurements | |
29 K = ceil(M*(0.25)); % Sparsity of x* | |
30 sigma = 0.000; % Additive noise variance | |
31 verbose = 1; % Print information | |
32 | |
33 % ALPS parameters | |
34 its = 600; % Maximum number of iterations | |
35 Ttol= 1e-6; % Convergence tolerance | |
36 mode = 1; % Binary representation of (SolveNewtonb, GradientDescentx, SolveNewtox) | |
37 memory = 1; % Memory of IHT method | |
38 tau = 0; % Momentum term | |
39 useCG = 0; % Usage of Conjugate gradients method | |
40 mu = 0; % Step size selection | |
41 | |
42 % Please refer to generate_matrix.m and generate_vector.m files | |
43 m_ensemble = 'Gaussian'; % Measurement matrix ensemble type | |
44 x_ensemble = 'Gaussian'; % Sparse vector ensemble type | |
45 | |
46 % reset(RandStream.getDefaultStream); | |
47 | |
48 %% Generate data | |
49 x = generate_vector(N, K, x_ensemble); | |
50 Phi = generate_matrix(M, N, m_ensemble); | |
51 noise = sigma*randn(M,1); | |
52 y = Phi*x + noise; | |
53 | |
54 %% ALPS reconstruction | |
55 disp('====================================================================='); | |
56 [x_hat, numiter, time, x_path] = AlgebraicPursuit(y, Phi, K, 'memory', memory, 'mode', mode, 'tolerance', Ttol, 'ALPSiterations', its, 'verbose', verbose, 'tau', tau, 'useCG', useCG, 'mu', mu); | |
57 if (numiter ~= -1) | |
58 str = sprintf('Error norm: %f ', norm(x-x_hat)); | |
59 disp(str); | |
60 end; | |
61 | |
62 %% Plot error per iteration | |
63 if (numiter ~= -1) | |
64 error = sqrt(sum(abs(x*ones(1,size(x_path,2))-x_path).^2)); | |
65 | |
66 set(0, 'DefaultAxesFontSize', 14); | |
67 figure; | |
68 semilogy(error,'LineWidth',3); hold on; | |
69 grid on; | |
70 semilogy((norm(noise))*ones(1,its),'m-','LineWidth',1); | |
71 | |
72 xlabel('[i]:iteration number') | |
73 ylabel('||x-x_i||') | |
74 axis([1 numiter + 5 10^-5 2*10^0]) | |
75 | |
76 legend(strcat('Time = [',num2str(time),']'), 'Noise Level'); | |
77 title(strcat('N = ', num2str(N), ', M = ', num2str(M), ', K = ', num2str(K))); | |
78 shg; | |
79 end; |