annotate examples/SMALL_solver_test.m @ 117:d120a9e52be5 sup_158_IMG_Processing_toolbox_

renaiming of SMALL_vmrse_type2.m
author Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk>
date Tue, 24 May 2011 16:15:05 +0100
parents 4302a91e6033
children 002ec1b2ceff
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@25 43
idamnjanovic@25 44
maria@83 45 % Centre for Digital Music, Queen Mary, University of London.
maria@83 46 % This file copyright 2009 Ivan Damnjanovic.
maria@83 47 %
maria@83 48 % This program is free software; you can redistribute it and/or
maria@83 49 % modify it under the terms of the GNU General Public License as
maria@83 50 % published by the Free Software Foundation; either version 2 of the
maria@83 51 % License, or (at your option) any later version. See the file
maria@83 52 % COPYING included with this distribution for more information.
maria@83 53 %%
idamnjanovic@1 54
idamnjanovic@20 55 fprintf('\n\nExample test of SMALL solvers against their counterparts on Sparco problems.\n\n');
idamnjanovic@1 56
idamnjanovic@1 57 %%
idamnjanovic@1 58 % Generate SPARCO problem
idamnjanovic@41 59 clear
idamnjanovic@4 60
idamnjanovic@1 61 SMALL.Problem = generateProblem(6, 'P', 6, 'm', 270,'n',1024, 'show');
idamnjanovic@1 62 %%
idamnjanovic@4 63 i=1;
idamnjanovic@20 64 % %%
idamnjanovic@20 65 % % SMALL Conjugate Gradient test
idamnjanovic@20 66 % SMALL.solver(i)=SMALL_init_solver;
idamnjanovic@20 67 % SMALL.solver(i).toolbox='SMALL';
idamnjanovic@20 68 % SMALL.solver(i).name='SMALL_cgp';
idamnjanovic@20 69 %
idamnjanovic@20 70 % % In the following string all parameters except matrix, measurement vector
idamnjanovic@20 71 % % and size of solution need to be specified. If you are not sure which
idamnjanovic@20 72 % % parameters are needed for particular solver type "help <Solver name>" in
idamnjanovic@20 73 % % MATLAB command line
idamnjanovic@20 74 %
idamnjanovic@20 75 % SMALL.solver(i).param='200, 1e-14';
idamnjanovic@20 76 %
idamnjanovic@20 77 % SMALL.solver(i)=SMALL_solve(SMALL.Problem,SMALL.solver(i));
idamnjanovic@20 78 %
idamnjanovic@20 79 %
idamnjanovic@20 80 % i=i+1;
idamnjanovic@1 81 %%
idamnjanovic@41 82 % SMALL Conjugate Gradient test
idamnjanovic@4 83 SMALL.solver(i)=SMALL_init_solver;
idamnjanovic@4 84 SMALL.solver(i).toolbox='SMALL';
idamnjanovic@41 85 SMALL.solver(i).name='SMALL_cgp';
idamnjanovic@1 86
idamnjanovic@1 87 % In the following string all parameters except matrix, measurement vector
idamnjanovic@1 88 % and size of solution need to be specified. If you are not sure which
idamnjanovic@1 89 % parameters are needed for particular solver type "help <Solver name>" in
idamnjanovic@1 90 % MATLAB command line
idamnjanovic@1 91
idamnjanovic@4 92 SMALL.solver(i).param='200, 1e-14';
idamnjanovic@1 93
idamnjanovic@41 94 SMALL.solver(i)=SMALL_solve(SMALL.Problem,SMALL.solver(i));
idamnjanovic@41 95
idamnjanovic@1 96
idamnjanovic@4 97 i=i+1;
idamnjanovic@41 98
idamnjanovic@1 99 %%
idamnjanovic@1 100 % SolveOMP from SparseLab test
idamnjanovic@1 101
idamnjanovic@4 102 SMALL.solver(i)=SMALL_init_solver;
idamnjanovic@4 103 SMALL.solver(i).toolbox='SparseLab';
idamnjanovic@4 104 SMALL.solver(i).name='SolveOMP';
idamnjanovic@1 105
idamnjanovic@1 106 % In the following string all parameters except matrix, measurement vector
idamnjanovic@1 107 % and size of solution need to be specified. If you are not sure which
idamnjanovic@1 108 % parameters are needed for particular solver type "help <Solver name>" in
idamnjanovic@1 109 % MATLAB command line
idamnjanovic@1 110
idamnjanovic@4 111 SMALL.solver(i).param='200, 0, 0, 0, 1e-14';
idamnjanovic@1 112
idamnjanovic@4 113 SMALL.solver(i)=SMALL_solve(SMALL.Problem, SMALL.solver(i));
idamnjanovic@1 114
idamnjanovic@4 115 i=i+1;
idamnjanovic@1 116
idamnjanovic@1 117 %%
idamnjanovic@41 118 % SMALL OMP with Cholesky update test
idamnjanovic@41 119 SMALL.solver(i)=SMALL_init_solver;
idamnjanovic@41 120 SMALL.solver(i).toolbox='SMALL';
idamnjanovic@41 121 SMALL.solver(i).name='SMALL_chol';
idamnjanovic@41 122
idamnjanovic@41 123 % In the following string all parameters except matrix, measurement vector
idamnjanovic@41 124 % and size of solution need to be specified. If you are not sure which
idamnjanovic@41 125 % parameters are needed for particular solver type "help <Solver name>" in
idamnjanovic@41 126 % MATLAB command line
idamnjanovic@41 127
idamnjanovic@41 128 SMALL.solver(i).param='200, 1e-14';
idamnjanovic@41 129
idamnjanovic@41 130 SMALL.solver(i)=SMALL_solve(SMALL.Problem, SMALL.solver(i));
idamnjanovic@41 131
idamnjanovic@41 132 i=i+1;
idamnjanovic@41 133
idamnjanovic@41 134 %%
idamnjanovic@1 135 % greed_pcgp from Sparsify test
idamnjanovic@1 136
idamnjanovic@4 137 SMALL.solver(i)=SMALL_init_solver;
idamnjanovic@4 138 SMALL.solver(i).toolbox='Sparsify';
idamnjanovic@4 139 SMALL.solver(i).name='greed_pcgp';
idamnjanovic@1 140
idamnjanovic@1 141 % In the following string all parameters except matrix, measurement vector
idamnjanovic@1 142 % and size of solution need to be specified. If you are not sure which
idamnjanovic@1 143 % parameters are needed for particular solver type "help <Solver name>" in
idamnjanovic@1 144 % MATLAB command line
idamnjanovic@1 145
idamnjanovic@4 146 SMALL.solver(i).param='''stopCrit'', ''M'', ''stopTol'', 200';
idamnjanovic@1 147
idamnjanovic@4 148 SMALL.solver(i)=SMALL_solve(SMALL.Problem, SMALL.solver(i));
idamnjanovic@4 149
idamnjanovic@4 150 %%
idamnjanovic@1 151
idamnjanovic@1 152 SMALL_plot(SMALL);
idamnjanovic@1 153
idamnjanovic@4 154
idamnjanovic@1 155
idamnjanovic@1 156
idamnjanovic@1 157 end % function SMALL_solver_test