annotate examples/ALPS solvers tests/SMALL_solver_test_ALPS.m @ 163:855025f4c779 ivand_dev

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