Mercurial > hg > smallbox
comparison examples/SMALL_solver_test.m @ 1:7750624e0c73 version0.5
(none)
author | idamnjanovic |
---|---|
date | Thu, 05 Nov 2009 16:36:01 +0000 |
parents | |
children | 2d7d8736ce6c |
comparison
equal
deleted
inserted
replaced
0:5181bee80bc1 | 1:7750624e0c73 |
---|---|
1 function SMALL_solver_test | |
2 % Example test of solvers from different toolboxes on Sparco compressed | |
3 % sensing problems | |
4 % | |
5 % The main purpose of this example is to show how to use SMALL structure | |
6 % to solve SPARCO compressed sensing problems (1-11) and compare results | |
7 % from different solvers. | |
8 % To generate SMALL.Problem part of structure you can use generateProblem | |
9 % function from Sparco toolbox giving the problem number and any | |
10 % additional parameters you might want to change. Alternatively, you can | |
11 % might want to consult sparco documentation to write a problem by | |
12 % yourself. There are four fields the must be specified in SMALL.Problem | |
13 % - A, b, sizeA and reconstruct. | |
14 % | |
15 % To generate SMALL.solver part of the structure you must specify three | |
16 % fields: | |
17 % | |
18 % SMALL.solver.toolbox - string with toolbox name is needed because | |
19 % different toolboxes are calling solver | |
20 % functions in different ways. | |
21 % SMALL.solver.name - its string representing solver name (e.g. | |
22 % SolveOMP) | |
23 % SMALL.solver.param - string that contains optional parameters for | |
24 % particular solver (all parameters you want to | |
25 % specify except A, b and size of solution) | |
26 % | |
27 % Every call to SMALL_solve function will generate following output: | |
28 % | |
29 % SMALL.solver.solution - contains solution vector x | |
30 % SMALL.solver.reconstructed - vector containing signal reconstructed | |
31 % from the solution | |
32 % SMALL.solver.time - time that solver spent to find the solution | |
33 % | |
34 % SMALL_plot function plots the SMALL.solver.solution and reconstructed | |
35 % against original signal. | |
36 % | |
37 % In this particular example we are testing SMALL_cgp, SMALL_chol, | |
38 % SolveOMP form SparseLab and greed_pcgp form Sparsify against "PROB006 | |
39 % Daubechies basis, Gaussian ensemble measurement basis, piecewise cubic | |
40 % polynomial signal" from Sparco. | |
41 % | |
42 % | |
43 % Ivan Damnjanovic 2009% | |
44 % | |
45 % SPARCO Copyright 2008, Ewout van den Berg and Michael P. Friedlander | |
46 % http://www.cs.ubc.ca/labs/scl/sparco | |
47 % $Id: exGPSR.m 1040 2008-06-26 20:29:02Z ewout78 $ | |
48 | |
49 fprintf('\n\nExample test of SMALL solver against their counterparts on Sparco problems.\n\n'); | |
50 | |
51 %% | |
52 % Generate SPARCO problem | |
53 | |
54 global SMALL | |
55 SMALL.Problem = generateProblem(6, 'P', 6, 'm', 270,'n',1024, 'show'); | |
56 %% | |
57 | |
58 %% | |
59 % SMALL Conjugate Gradient test | |
60 | |
61 SMALL.solver.toolbox='SMALL'; | |
62 SMALL.solver.name='SMALL_cgp'; | |
63 | |
64 % In the following string all parameters except matrix, measurement vector | |
65 % and size of solution need to be specified. If you are not sure which | |
66 % parameters are needed for particular solver type "help <Solver name>" in | |
67 % MATLAB command line | |
68 | |
69 SMALL.solver.param='200, 1e-14'; | |
70 | |
71 SMALL=SMALL_solve(SMALL); | |
72 | |
73 | |
74 SMALL_plot(SMALL); | |
75 | |
76 %% | |
77 % SMALL OMP with Cholesky update test | |
78 | |
79 SMALL.solver.toolbox='SMALL'; | |
80 SMALL.solver.name='SMALL_chol'; | |
81 | |
82 % In the following string all parameters except matrix, measurement vector | |
83 % and size of solution need to be specified. If you are not sure which | |
84 % parameters are needed for particular solver type "help <Solver name>" in | |
85 % MATLAB command line | |
86 | |
87 SMALL.solver.param='200, 1e-14'; | |
88 | |
89 SMALL=SMALL_solve(SMALL); | |
90 | |
91 SMALL_plot(SMALL); | |
92 %% | |
93 % SolveOMP from SparseLab test | |
94 | |
95 SMALL.solver.toolbox='SparseLab'; | |
96 SMALL.solver.name='SolveOMP'; | |
97 | |
98 % In the following string all parameters except matrix, measurement vector | |
99 % and size of solution need to be specified. If you are not sure which | |
100 % parameters are needed for particular solver type "help <Solver name>" in | |
101 % MATLAB command line | |
102 | |
103 SMALL.solver.param='200, 0, 0, 0, 1e-14'; | |
104 | |
105 SMALL=SMALL_solve(SMALL); | |
106 | |
107 SMALL_plot(SMALL); | |
108 | |
109 %% | |
110 % greed_pcgp from Sparsify test | |
111 | |
112 SMALL.solver.toolbox='Sparsify'; | |
113 SMALL.solver.name='greed_pcgp'; | |
114 | |
115 % In the following string all parameters except matrix, measurement vector | |
116 % and size of solution need to be specified. If you are not sure which | |
117 % parameters are needed for particular solver type "help <Solver name>" in | |
118 % MATLAB command line | |
119 | |
120 SMALL.solver.param='''stopCrit'', ''M'', ''stopTol'', 200'; | |
121 | |
122 SMALL=SMALL_solve(SMALL); | |
123 | |
124 SMALL_plot(SMALL); | |
125 | |
126 %% | |
127 | |
128 | |
129 end % function SMALL_solver_test |