forked from sustainable-computing/dist_grid_identification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runDT.m
58 lines (42 loc) · 1.44 KB
/
runDT.m
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
function [DeltaY, NewY, norm_diff] = runDT(V, I, OldY, lambda, iter_end)
% lambda banlance the weight of fitness and complexity
% iteration = 1
% here, I only implement a decentralized algorithm which is
% computationally efficient
[NODES,~] = size(V);
% M = kron(eye(), V');
delta2 = 1e-4;
y_stack = zeros(2*NODES, NODES);
DeltaY = zeros(NODES, NODES);
I_diff = I - OldY*V;
for index = 1 : NODES
% fprintf('This is node %d \n', index);
y = conj(I_diff(index,:))';
phi = conj(V)';
re_phi = real(phi);
im_phi = imag(phi);
re_y = real(y);
im_y = imag(y);
phi = [re_phi -im_phi; im_phi re_phi];
y = [re_y; im_y];
for iter=1:iter_end
U=ones(2*NODES, iter_end);
w_estimate=zeros(2*NODES, iter_end);
cvx_begin quiet
% cvx_solver sedumi
% cvx_solver sdpt3
% Real version
variable W(2*NODES)
minimize (lambda*norm( U(:,iter).*W, 1 )+ norm((phi* W-y),2) )
% subject to
% ones(1,NODES) * W(1:NODES) == 0;
% ones(1,NODES) * W(NODES+1: 2*NODES) == 0;
cvx_end
w_estimate(:,iter)=W;
end
y_stack(:,index) = w_estimate(:,end);
DeltaY(:,index) = y_stack(1:NODES,index) + 1i * y_stack(NODES+1:2*NODES, index);
end
NewY = DeltaY + OldY;
norm_diff = norm(NewY, 'fro');
end