annotate examples/SMALL_solver_test.m @ 45:b9465d2bb3b0

(none)
author idamnjanovic
date Mon, 14 Mar 2011 15:42:52 +0000
parents 83de4ea524df
children 4302a91e6033
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@25 5 %
idamnjanovic@25 6 % Centre for Digital Music, Queen Mary, University of London.
idamnjanovic@25 7 % This file copyright 2009 Ivan Damnjanovic.
idamnjanovic@25 8 %
idamnjanovic@25 9 % This program is free software; you can redistribute it and/or
idamnjanovic@25 10 % modify it under the terms of the GNU General Public License as
idamnjanovic@25 11 % published by the Free Software Foundation; either version 2 of the
idamnjanovic@25 12 % License, or (at your option) any later version. See the file
idamnjanovic@25 13 % COPYING included with this distribution for more information.
idamnjanovic@25 14 %
idamnjanovic@1 15 % The main purpose of this example is to show how to use SMALL structure
idamnjanovic@1 16 % to solve SPARCO compressed sensing problems (1-11) and compare results
idamnjanovic@1 17 % from different solvers.
idamnjanovic@1 18 % To generate SMALL.Problem part of structure you can use generateProblem
idamnjanovic@1 19 % function from Sparco toolbox giving the problem number and any
idamnjanovic@1 20 % additional parameters you might want to change. Alternatively, you can
idamnjanovic@1 21 % might want to consult sparco documentation to write a problem by
idamnjanovic@1 22 % yourself. There are four fields the must be specified in SMALL.Problem
idamnjanovic@1 23 % - A, b, sizeA and reconstruct.
idamnjanovic@1 24 %
idamnjanovic@1 25 % To generate SMALL.solver part of the structure you must specify three
idamnjanovic@1 26 % fields:
idamnjanovic@1 27 %
idamnjanovic@1 28 % SMALL.solver.toolbox - string with toolbox name is needed because
idamnjanovic@1 29 % different toolboxes are calling solver
idamnjanovic@1 30 % functions in different ways.
idamnjanovic@1 31 % SMALL.solver.name - its string representing solver name (e.g.
idamnjanovic@1 32 % SolveOMP)
idamnjanovic@1 33 % SMALL.solver.param - string that contains optional parameters for
idamnjanovic@1 34 % particular solver (all parameters you want to
idamnjanovic@1 35 % specify except A, b and size of solution)
idamnjanovic@1 36 %
idamnjanovic@1 37 % Every call to SMALL_solve function will generate following output:
idamnjanovic@1 38 %
idamnjanovic@1 39 % SMALL.solver.solution - contains solution vector x
idamnjanovic@1 40 % SMALL.solver.reconstructed - vector containing signal reconstructed
idamnjanovic@1 41 % from the solution
idamnjanovic@1 42 % SMALL.solver.time - time that solver spent to find the solution
idamnjanovic@1 43 %
idamnjanovic@1 44 % SMALL_plot function plots the SMALL.solver.solution and reconstructed
idamnjanovic@1 45 % against original signal.
idamnjanovic@1 46 %
idamnjanovic@1 47 % In this particular example we are testing SMALL_cgp, SMALL_chol,
idamnjanovic@1 48 % SolveOMP form SparseLab and greed_pcgp form Sparsify against "PROB006
idamnjanovic@1 49 % Daubechies basis, Gaussian ensemble measurement basis, piecewise cubic
idamnjanovic@1 50 % polynomial signal" from Sparco.
idamnjanovic@1 51 %
idamnjanovic@1 52 %
idamnjanovic@25 53
idamnjanovic@25 54
idamnjanovic@1 55
idamnjanovic@20 56 fprintf('\n\nExample test of SMALL solvers against their counterparts on Sparco problems.\n\n');
idamnjanovic@1 57
idamnjanovic@1 58 %%
idamnjanovic@1 59 % Generate SPARCO problem
idamnjanovic@41 60 clear
idamnjanovic@4 61
idamnjanovic@1 62 SMALL.Problem = generateProblem(6, 'P', 6, 'm', 270,'n',1024, 'show');
idamnjanovic@1 63 %%
idamnjanovic@4 64 i=1;
idamnjanovic@20 65 % %%
idamnjanovic@20 66 % % SMALL Conjugate Gradient test
idamnjanovic@20 67 % SMALL.solver(i)=SMALL_init_solver;
idamnjanovic@20 68 % SMALL.solver(i).toolbox='SMALL';
idamnjanovic@20 69 % SMALL.solver(i).name='SMALL_cgp';
idamnjanovic@20 70 %
idamnjanovic@20 71 % % In the following string all parameters except matrix, measurement vector
idamnjanovic@20 72 % % and size of solution need to be specified. If you are not sure which
idamnjanovic@20 73 % % parameters are needed for particular solver type "help <Solver name>" in
idamnjanovic@20 74 % % MATLAB command line
idamnjanovic@20 75 %
idamnjanovic@20 76 % SMALL.solver(i).param='200, 1e-14';
idamnjanovic@20 77 %
idamnjanovic@20 78 % SMALL.solver(i)=SMALL_solve(SMALL.Problem,SMALL.solver(i));
idamnjanovic@20 79 %
idamnjanovic@20 80 %
idamnjanovic@20 81 % i=i+1;
idamnjanovic@1 82 %%
idamnjanovic@41 83 % SMALL Conjugate Gradient test
idamnjanovic@4 84 SMALL.solver(i)=SMALL_init_solver;
idamnjanovic@4 85 SMALL.solver(i).toolbox='SMALL';
idamnjanovic@41 86 SMALL.solver(i).name='SMALL_cgp';
idamnjanovic@1 87
idamnjanovic@1 88 % In the following string all parameters except matrix, measurement vector
idamnjanovic@1 89 % and size of solution need to be specified. If you are not sure which
idamnjanovic@1 90 % parameters are needed for particular solver type "help <Solver name>" in
idamnjanovic@1 91 % MATLAB command line
idamnjanovic@1 92
idamnjanovic@4 93 SMALL.solver(i).param='200, 1e-14';
idamnjanovic@1 94
idamnjanovic@41 95 SMALL.solver(i)=SMALL_solve(SMALL.Problem,SMALL.solver(i));
idamnjanovic@41 96
idamnjanovic@1 97
idamnjanovic@4 98 i=i+1;
idamnjanovic@41 99
idamnjanovic@1 100 %%
idamnjanovic@1 101 % SolveOMP from SparseLab test
idamnjanovic@1 102
idamnjanovic@4 103 SMALL.solver(i)=SMALL_init_solver;
idamnjanovic@4 104 SMALL.solver(i).toolbox='SparseLab';
idamnjanovic@4 105 SMALL.solver(i).name='SolveOMP';
idamnjanovic@1 106
idamnjanovic@1 107 % In the following string all parameters except matrix, measurement vector
idamnjanovic@1 108 % and size of solution need to be specified. If you are not sure which
idamnjanovic@1 109 % parameters are needed for particular solver type "help <Solver name>" in
idamnjanovic@1 110 % MATLAB command line
idamnjanovic@1 111
idamnjanovic@4 112 SMALL.solver(i).param='200, 0, 0, 0, 1e-14';
idamnjanovic@1 113
idamnjanovic@4 114 SMALL.solver(i)=SMALL_solve(SMALL.Problem, SMALL.solver(i));
idamnjanovic@1 115
idamnjanovic@4 116 i=i+1;
idamnjanovic@1 117
idamnjanovic@1 118 %%
idamnjanovic@41 119 % SMALL OMP with Cholesky update test
idamnjanovic@41 120 SMALL.solver(i)=SMALL_init_solver;
idamnjanovic@41 121 SMALL.solver(i).toolbox='SMALL';
idamnjanovic@41 122 SMALL.solver(i).name='SMALL_chol';
idamnjanovic@41 123
idamnjanovic@41 124 % In the following string all parameters except matrix, measurement vector
idamnjanovic@41 125 % and size of solution need to be specified. If you are not sure which
idamnjanovic@41 126 % parameters are needed for particular solver type "help <Solver name>" in
idamnjanovic@41 127 % MATLAB command line
idamnjanovic@41 128
idamnjanovic@41 129 SMALL.solver(i).param='200, 1e-14';
idamnjanovic@41 130
idamnjanovic@41 131 SMALL.solver(i)=SMALL_solve(SMALL.Problem, SMALL.solver(i));
idamnjanovic@41 132
idamnjanovic@41 133 i=i+1;
idamnjanovic@41 134
idamnjanovic@41 135 %%
idamnjanovic@1 136 % greed_pcgp from Sparsify test
idamnjanovic@1 137
idamnjanovic@4 138 SMALL.solver(i)=SMALL_init_solver;
idamnjanovic@4 139 SMALL.solver(i).toolbox='Sparsify';
idamnjanovic@4 140 SMALL.solver(i).name='greed_pcgp';
idamnjanovic@1 141
idamnjanovic@1 142 % In the following string all parameters except matrix, measurement vector
idamnjanovic@1 143 % and size of solution need to be specified. If you are not sure which
idamnjanovic@1 144 % parameters are needed for particular solver type "help <Solver name>" in
idamnjanovic@1 145 % MATLAB command line
idamnjanovic@1 146
idamnjanovic@4 147 SMALL.solver(i).param='''stopCrit'', ''M'', ''stopTol'', 200';
idamnjanovic@1 148
idamnjanovic@4 149 SMALL.solver(i)=SMALL_solve(SMALL.Problem, SMALL.solver(i));
idamnjanovic@4 150
idamnjanovic@4 151 %%
idamnjanovic@1 152
idamnjanovic@1 153 SMALL_plot(SMALL);
idamnjanovic@1 154
idamnjanovic@4 155
idamnjanovic@1 156
idamnjanovic@1 157
idamnjanovic@1 158 end % function SMALL_solver_test