annotate examples/SMALL_solver_test.m @ 5:f44689e95ea4

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