idamnjanovic@1: function SMALL_solver_test idamnjanovic@1: % Example test of solvers from different toolboxes on Sparco compressed idamnjanovic@1: % sensing problems idamnjanovic@1: % idamnjanovic@1: % The main purpose of this example is to show how to use SMALL structure idamnjanovic@1: % to solve SPARCO compressed sensing problems (1-11) and compare results idamnjanovic@1: % from different solvers. idamnjanovic@1: % To generate SMALL.Problem part of structure you can use generateProblem idamnjanovic@1: % function from Sparco toolbox giving the problem number and any idamnjanovic@1: % additional parameters you might want to change. Alternatively, you can idamnjanovic@1: % might want to consult sparco documentation to write a problem by idamnjanovic@1: % yourself. There are four fields the must be specified in SMALL.Problem idamnjanovic@1: % - A, b, sizeA and reconstruct. idamnjanovic@1: % idamnjanovic@1: % To generate SMALL.solver part of the structure you must specify three idamnjanovic@1: % fields: idamnjanovic@1: % idamnjanovic@1: % SMALL.solver.toolbox - string with toolbox name is needed because idamnjanovic@1: % different toolboxes are calling solver idamnjanovic@1: % functions in different ways. idamnjanovic@1: % SMALL.solver.name - its string representing solver name (e.g. idamnjanovic@1: % SolveOMP) idamnjanovic@1: % SMALL.solver.param - string that contains optional parameters for idamnjanovic@1: % particular solver (all parameters you want to idamnjanovic@1: % specify except A, b and size of solution) idamnjanovic@1: % idamnjanovic@1: % Every call to SMALL_solve function will generate following output: idamnjanovic@1: % idamnjanovic@1: % SMALL.solver.solution - contains solution vector x idamnjanovic@1: % SMALL.solver.reconstructed - vector containing signal reconstructed idamnjanovic@1: % from the solution idamnjanovic@1: % SMALL.solver.time - time that solver spent to find the solution idamnjanovic@1: % idamnjanovic@1: % SMALL_plot function plots the SMALL.solver.solution and reconstructed idamnjanovic@1: % against original signal. idamnjanovic@1: % idamnjanovic@1: % In this particular example we are testing SMALL_cgp, SMALL_chol, idamnjanovic@1: % SolveOMP form SparseLab and greed_pcgp form Sparsify against "PROB006 idamnjanovic@1: % Daubechies basis, Gaussian ensemble measurement basis, piecewise cubic idamnjanovic@1: % polynomial signal" from Sparco. idamnjanovic@1: % idamnjanovic@1: % idamnjanovic@1: % Ivan Damnjanovic 2009% idamnjanovic@1: % idamnjanovic@1: % SPARCO Copyright 2008, Ewout van den Berg and Michael P. Friedlander idamnjanovic@1: % http://www.cs.ubc.ca/labs/scl/sparco idamnjanovic@1: % $Id: exGPSR.m 1040 2008-06-26 20:29:02Z ewout78 $ idamnjanovic@1: idamnjanovic@1: fprintf('\n\nExample test of SMALL solver against their counterparts on Sparco problems.\n\n'); idamnjanovic@1: idamnjanovic@1: %% idamnjanovic@1: % Generate SPARCO problem idamnjanovic@1: idamnjanovic@1: global SMALL idamnjanovic@1: SMALL.Problem = generateProblem(6, 'P', 6, 'm', 270,'n',1024, 'show'); idamnjanovic@1: %% idamnjanovic@1: idamnjanovic@1: %% idamnjanovic@1: % SMALL Conjugate Gradient test idamnjanovic@1: idamnjanovic@1: SMALL.solver.toolbox='SMALL'; idamnjanovic@1: SMALL.solver.name='SMALL_cgp'; idamnjanovic@1: idamnjanovic@1: % In the following string all parameters except matrix, measurement vector idamnjanovic@1: % and size of solution need to be specified. If you are not sure which idamnjanovic@1: % parameters are needed for particular solver type "help " in idamnjanovic@1: % MATLAB command line idamnjanovic@1: idamnjanovic@1: SMALL.solver.param='200, 1e-14'; idamnjanovic@1: idamnjanovic@1: SMALL=SMALL_solve(SMALL); idamnjanovic@1: idamnjanovic@1: idamnjanovic@1: SMALL_plot(SMALL); idamnjanovic@1: idamnjanovic@1: %% idamnjanovic@1: % SMALL OMP with Cholesky update test idamnjanovic@1: idamnjanovic@1: SMALL.solver.toolbox='SMALL'; idamnjanovic@1: SMALL.solver.name='SMALL_chol'; idamnjanovic@1: idamnjanovic@1: % In the following string all parameters except matrix, measurement vector idamnjanovic@1: % and size of solution need to be specified. If you are not sure which idamnjanovic@1: % parameters are needed for particular solver type "help " in idamnjanovic@1: % MATLAB command line idamnjanovic@1: idamnjanovic@1: SMALL.solver.param='200, 1e-14'; idamnjanovic@1: idamnjanovic@1: SMALL=SMALL_solve(SMALL); idamnjanovic@1: idamnjanovic@1: SMALL_plot(SMALL); idamnjanovic@1: %% idamnjanovic@1: % SolveOMP from SparseLab test idamnjanovic@1: idamnjanovic@1: SMALL.solver.toolbox='SparseLab'; idamnjanovic@1: SMALL.solver.name='SolveOMP'; idamnjanovic@1: idamnjanovic@1: % In the following string all parameters except matrix, measurement vector idamnjanovic@1: % and size of solution need to be specified. If you are not sure which idamnjanovic@1: % parameters are needed for particular solver type "help " in idamnjanovic@1: % MATLAB command line idamnjanovic@1: idamnjanovic@1: SMALL.solver.param='200, 0, 0, 0, 1e-14'; idamnjanovic@1: idamnjanovic@1: SMALL=SMALL_solve(SMALL); idamnjanovic@1: idamnjanovic@1: SMALL_plot(SMALL); idamnjanovic@1: idamnjanovic@1: %% idamnjanovic@1: % greed_pcgp from Sparsify test idamnjanovic@1: idamnjanovic@1: SMALL.solver.toolbox='Sparsify'; idamnjanovic@1: SMALL.solver.name='greed_pcgp'; idamnjanovic@1: idamnjanovic@1: % In the following string all parameters except matrix, measurement vector idamnjanovic@1: % and size of solution need to be specified. If you are not sure which idamnjanovic@1: % parameters are needed for particular solver type "help " in idamnjanovic@1: % MATLAB command line idamnjanovic@1: idamnjanovic@1: SMALL.solver.param='''stopCrit'', ''M'', ''stopTol'', 200'; idamnjanovic@1: idamnjanovic@1: SMALL=SMALL_solve(SMALL); idamnjanovic@1: idamnjanovic@1: SMALL_plot(SMALL); idamnjanovic@1: idamnjanovic@1: %% idamnjanovic@1: idamnjanovic@1: idamnjanovic@1: end % function SMALL_solver_test