-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathonedimmin.jl
34 lines (30 loc) · 951 Bytes
/
onedimmin.jl
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
using LinearAlgebra
include("ConvHullProj.jl")
function onedimmin(X, H, A, B, i, j, lambda, m, n ,k)
max_iter = 50
f = zeros(max_iter,1)
f[1] = R(X, H, A, B,lambda)
counter = 1
diff = 1e10
t = 0
while (diff >= f[1]/1e8 && counter < max_iter)
U = X - A*H
V = H - B*X
global t = max(-H[i,j],(transpose(A[:,i])*U[:,j] - lambda*V[i,j])/(lambda + norm(A[:,i])^2))
H[i,j] = t + H[i,j]
temp, a = ConvHullProj(transpose(H[i,:]), transpose(X),(B[i,:]))
B[i,:] = transpose(a)
for r=1:m
tt, a = ConvHullProj(transpose(X[r,:]), transpose(H),(A[r,:]))
A[r,:] = transpose(a)
end
counter = counter + 1
f[counter] = R(X,H,A,B, lambda)
diff = f[counter-1] - f[counter]
end
f = f[1:counter]
return t+H[i,j], A, B, f[counter]
end
function R(X, H, A, B, lambda)
return norm(X - A*H)^2 + lambda*norm(H - B*X)^2
end