-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathS150319_SciClusterOptiom.asv
70 lines (61 loc) · 1.06 KB
/
S150319_SciClusterOptiom.asv
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
65
66
67
68
69
70
% S_SciClusterOptimization
%% original output
ND = 4;
ND1 = 4;
expdist2 = round(rand(ND));
% disp(expdist2)
%%
rho = zeros(1,ND);
tic
for i=1:ND-1
for j=i+1:ND
rho(i)=rho(i)+expdist2(i,j);
rho(j)=rho(j)+expdist2(i,j);
end
disp(rho);
end
toc %7.053022
rho1=rho;
% disp(rho(1:ND1))
% 16 2 3 13
% 5 11 10 8
% 9 7 6 12
% 4 14 15 1
% ----------------------------------
% 18 2 3 13
%
% 18 20 13 21
%
% 18 20 25 33
%% optimized 1
rho = zeros(1,ND);
tic
for i=1:ND-1
j = i+1:ND;
rho(i) = rho(i)*(ND-i) + sum(expdist2(i,j));
rho(j) = rho(j) + expdist2(i,j);
disp(rho);
end
toc %3.847825
% disp(rho(1:ND1))
rho2=rho;
%%
rhod=rho1-rho2;
rhod(1:ND1)
% %% optimize 2
% tic
% mr1 = triu(expdist2,1);
% vr1 = sum(mr1);
%
%
% toc
%% hybrid
for i=1:ND-1
for j=i+1:ND
rho(i)=rho(i)+expdist2(i,j);
rho(j)=rho(j)+expdist2(i,j);
end
j = i+1:ND;
rho1(i) = rho1(i)*(ND-i) + sum(expdist2(i,j));
rho1(j) = rho1(j) + expdist2(i,j);
end