comparison pyCSalgos/ABS/ABSmixed.py @ 67:a8d96e67717e

Added the Analysis-By-Synthesis algorithms used in the papers "Analysis-based sparse reconstruction with synthesis-based solvers", "Choosing Analysis or Synthesis Recovery for Sparse Reconstruction" and "A generalization of synthesis and analysis sparsity"
author Nic Cleju <nikcleju@gmail.com>
date Tue, 09 Jul 2013 14:21:10 +0300
parents
children
comparison
equal deleted inserted replaced
66:ee10ffb60428 67:a8d96e67717e
1 # -*- coding: utf-8 -*-
2 """
3 Algorithms for approximate analysis recovery based on synthesis solvers (a.k.a. Analysis by Synthesis, ABS).
4 Approximate reconstruction, ABS-mixed.
5
6 Author: Nicolae Cleju
7 """
8 __author__ = "Nicolae Cleju"
9 __license__ = "GPL"
10 __email__ = "nikcleju@gmail.com"
11
12
13 import numpy
14
15 # Import synthesis solvers from pyCSalgos package
16 import pyCSalgos.BP.l1qec
17 import pyCSalgos.SL0.SL0_approx
18
19 def bp(y,M,Omega,epsilon, x0, lbtol=1e-3, mu=10, cgtol=1e-8, cgmaxiter=200, verbose=False):
20 """
21 ABS-mixed: Basis Pursuit (based on l1magic toolbox)
22 """
23 N,n = Omega.shape
24 D = numpy.linalg.pinv(Omega)
25 U,S,Vt = numpy.linalg.svd(D)
26 Aeps = numpy.dot(M,D)
27 Aexact = Vt[-(N-n):,:]
28
29 return numpy.dot(D , pyCSalgos.BP.l1qec.l1qec_logbarrier(x0,Aeps,Aeps.T,y,epsilon,Aexact,Aexact.T,numpy.zeros(N-n), lbtol, mu, cgtol, cgmaxiter, verbose))
30
31 def sl0(y,M,Omega,epsilon, sigma_min, sigma_decrease_factor=0.5, mu_0=2, L=3, Aeps_pinv=None, Aexact_pinv=None, true_s=None):
32 """
33 ABS-mixed: Smooth L0 (SL0)
34 """
35 N,n = Omega.shape
36 D = numpy.linalg.pinv(Omega)
37 U,S,Vt = numpy.linalg.svd(D)
38 Aeps = numpy.dot(M,D)
39 Aexact = Vt[-(N-n):,:]
40
41 #return numpy.dot(D, pyCSalgos.SL0.SL0_approx.SL0_approx_analysis(Aeps,Aexact,y,epsilon,sigma_min,sigma_decrease_factor,mu_0,L,Aeps_pinv,Aexact_pinv,true_s))
42 #return numpy.dot(D, pyCSalgos.SL0.SL0_approx.SL0_robust_analysis(Aeps,Aexact,y,epsilon,sigma_min,sigma_decrease_factor,mu_0,L,Aeps_pinv,Aexact_pinv,true_s))
43 #return numpy.dot(D, pyCSalgos.SL0.SL0_approx.SL0_approx_analysis_unconstrained(Aeps,Aexact,y,epsilon,sigma_min,sigma_decrease_factor,mu_0,L,Aeps_pinv,Aexact_pinv,true_s))
44 return numpy.dot(D, pyCSalgos.SL0.SL0_approx.SL0_approx_analysis_dai(Aeps,Aexact,y,epsilon,sigma_min,sigma_decrease_factor,mu_0,L,Aeps_pinv,Aexact_pinv,true_s))
45