-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEstimation_algorithm.py
More file actions
64 lines (45 loc) · 1.33 KB
/
Estimation_algorithm.py
File metadata and controls
64 lines (45 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import numpy as np
import scipy.linalg as scilin
def SpectrogramSeparation(Sz,K,Theta,alpha,beta,gamma,Niter):
N,M = np.shape(Sz)
c = np.zeros(N-1)
c[0] = -1
r = np.zeros(N)
r[0:2] = [-1, 1]
B = scilin.toeplitz(c,r)
Mat = np.eye(N) + alpha * (B.T @ B)
Sy = np.zeros((N,M))
L = np.zeros(K)
k=0
criterion = np.inf
Lprec = 0
while k<K and criterion>Theta:
Sx = np.linalg.solve(Mat, Sz-Sy)
Sy = solveSy(Sz-Sx,gamma,Niter,Sy,beta)
L[k] = costFunction(Sz,Sx,Sy,alpha,beta,B)
if k>0:
criterion = (Lprec-L[k])/Lprec
Lprec = L[k]
k = k+1
return Sx,Sy,L,k
def solveSy(S,gamma,Niter,x,beta):
t = 1
z = x
for ind_iter in range(Niter):
xnew = proxL1(z - 2*gamma*(z-S), gamma*beta )
tnew = (1+np.sqrt(4*t**2+1))/2
eta = (t-1)/tnew
z = xnew + eta * (xnew-x)
x = xnew
t = tnew
return x
def proxL1(u,xi):
v = np.abs(u)-xi
tmp = np.where(v>0, v, 0)
v = np.sign(u) * tmp
return v
def costFunction(Sz,Sx,Sy,alpha,beta,B):
term1 = np.linalg.norm(Sz-Sx-Sy)
term2 = alpha * np.linalg.norm( B @ Sx )
term3 = beta * np.linalg.norm(Sy.flatten(),1)
return term1 + term2 + term3