ivan@154: %% Example test of solvers from different toolboxes on Sparco problem 6 ivan@154: % ivan@154: % The main purpose of this example is to show how to use SMALL structure ivan@154: % to solve SPARCO compressed sensing problems (1-11) and compare results ivan@154: % from different solvers. ivan@154: % To generate SMALL.Problem part of structure you can use generateProblem ivan@154: % function from Sparco toolbox giving the problem number and any ivan@154: % additional parameters you might want to change. Alternatively, you can ivan@154: % might want to consult sparco documentation to write a problem by ivan@154: % yourself. There are four fields the must be specified in SMALL.Problem ivan@154: % - A, b, sizeA and reconstruct. ivan@154: % ivan@154: % To generate SMALL.solver part of the structure you must specify three ivan@154: % fields: ivan@154: % ivan@154: % SMALL.solver.toolbox - string with toolbox name is needed because ivan@154: % different toolboxes are calling solver ivan@154: % functions in different ways. ivan@154: % SMALL.solver.name - its string representing solver name (e.g. ivan@154: % SolveOMP) ivan@154: % SMALL.solver.param - string that contains optional parameters for ivan@154: % particular solver (all parameters you want to ivan@154: % specify except A, b and size of solution) ivan@154: % ivan@154: % Every call to SMALL_solve function will generate following output: ivan@154: % ivan@154: % SMALL.solver.solution - contains solution vector x ivan@154: % SMALL.solver.reconstructed - vector containing signal reconstructed ivan@154: % from the solution ivan@154: % SMALL.solver.time - time that solver spent to find the solution ivan@154: % ivan@154: % SMALL_plot function plots the SMALL.solver.solution and reconstructed ivan@154: % against original signal. ivan@154: % ivan@154: % In this particular example we are testing SMALL_cgp, SMALL_chol, ivan@154: % SolveOMP form SparseLab and greed_pcgp form Sparsify against "PROB006 ivan@154: % Daubechies basis, Gaussian ensemble measurement basis, piecewise cubic ivan@154: % polynomial signal" from Sparco. ivan@154: % ivan@154: % ivan@154: ivan@154: ivan@154: % Centre for Digital Music, Queen Mary, University of London. ivan@154: % This file copyright 2009 Ivan Damnjanovic. ivan@154: % ivan@154: % This program is free software; you can redistribute it and/or ivan@154: % modify it under the terms of the GNU General Public License as ivan@154: % published by the Free Software Foundation; either version 2 of the ivan@154: % License, or (at your option) any later version. See the file ivan@154: % COPYING included with this distribution for more information. ivan@154: %% ivan@154: ivan@154: fprintf('\n\nExample test of SMALL solvers against their counterparts on Sparco problems.\n\n'); ivan@154: ivan@154: %% ivan@154: % Generate SPARCO problem ivan@154: clear ivan@154: ivan@154: SMALL.Problem = generateProblem(6, 'P', 6, 'm', 2*500,'n',2*1024, 'show'); ivan@154: ivan@154: SMALL.Problem.A = opToMatrix(SMALL.Problem.A, 1); ivan@154: ivan@154: %% ivan@154: i=1; ivan@154: %% ivan@154: % ALPS test ivan@154: SMALL.solver(i) = SMALL_init_solver; ivan@154: SMALL.solver(i).toolbox = 'ALPS'; ivan@154: SMALL.solver(i).name = 'AlgebraicPursuit'; ivan@154: ivan@154: % In the following string all parameters except matrix, measurement vector ivan@154: % and size of solution need to be specified. If you are not sure which ivan@154: % parameters are needed for particular solver type "help " in ivan@154: % MATLAB command line ivan@154: ivan@154: SMALL.solver(i).param=struct(... ivan@154: 'sparsity', 125,... ivan@154: 'memory', 0,... ivan@154: 'mode', 1,... ivan@154: 'iternum', 50,... ivan@154: 'tolerance', 1e-14'); ivan@154: ivan@154: SMALL.solver(i)=SMALL_solve(SMALL.Problem,SMALL.solver(i)); ivan@154: ivan@154: ivan@154: i=i+1; ivan@154: %% ivan@154: % SMALL Conjugate Gradient test ivan@154: SMALL.solver(i)=SMALL_init_solver; ivan@154: SMALL.solver(i).toolbox='SMALL'; ivan@163: SMALL.solver(i).name='SMALL_pcgp'; ivan@154: ivan@154: % In the following string all parameters except matrix, measurement vector ivan@154: % and size of solution need to be specified. If you are not sure which ivan@154: % parameters are needed for particular solver type "help " in ivan@154: % MATLAB command line ivan@154: ivan@154: SMALL.solver(i).param='200, 1e-14'; ivan@154: ivan@154: SMALL.solver(i)=SMALL_solve(SMALL.Problem,SMALL.solver(i)); ivan@154: ivan@154: ivan@154: i=i+1; ivan@154: ivan@154: %% ivan@154: % SolveOMP from SparseLab test ivan@154: ivan@154: SMALL.solver(i)=SMALL_init_solver; ivan@154: SMALL.solver(i).toolbox='SparseLab'; ivan@154: SMALL.solver(i).name='SolveOMP'; ivan@154: ivan@154: % In the following string all parameters except matrix, measurement vector ivan@154: % and size of solution need to be specified. If you are not sure which ivan@154: % parameters are needed for particular solver type "help " in ivan@154: % MATLAB command line ivan@154: ivan@154: SMALL.solver(i).param='200, 0, 0, 0, 1e-14'; ivan@154: ivan@154: SMALL.solver(i)=SMALL_solve(SMALL.Problem, SMALL.solver(i)); ivan@154: ivan@154: i=i+1; ivan@154: ivan@154: %% ivan@154: % SMALL OMP with Cholesky update test ivan@154: SMALL.solver(i)=SMALL_init_solver; ivan@154: SMALL.solver(i).toolbox='SMALL'; ivan@154: SMALL.solver(i).name='SMALL_chol'; ivan@154: ivan@154: % In the following string all parameters except matrix, measurement vector ivan@154: % and size of solution need to be specified. If you are not sure which ivan@154: % parameters are needed for particular solver type "help " in ivan@154: % MATLAB command line ivan@154: ivan@154: SMALL.solver(i).param='200, 1e-14'; ivan@154: ivan@154: SMALL.solver(i)=SMALL_solve(SMALL.Problem, SMALL.solver(i)); ivan@154: ivan@154: i=i+1; ivan@154: ivan@154: %% ivan@154: % greed_pcgp from Sparsify test ivan@154: ivan@154: SMALL.solver(i)=SMALL_init_solver; ivan@154: SMALL.solver(i).toolbox='Sparsify'; ivan@154: SMALL.solver(i).name='greed_pcgp'; ivan@154: ivan@154: % In the following string all parameters except matrix, measurement vector ivan@154: % and size of solution need to be specified. If you are not sure which ivan@154: % parameters are needed for particular solver type "help " in ivan@154: % MATLAB command line ivan@154: ivan@154: SMALL.solver(i).param='''stopCrit'', ''M'', ''stopTol'', 200'; ivan@154: ivan@154: SMALL.solver(i)=SMALL_solve(SMALL.Problem, SMALL.solver(i)); ivan@154: ivan@154: %% ivan@154: ivan@154: SMALL_plot(SMALL); ivan@154: ivan@154: ivan@154: ivan@154: ivan@154: