-
Notifications
You must be signed in to change notification settings - Fork 14
/
testFindSup.m
103 lines (80 loc) · 1.68 KB
/
testFindSup.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
%=========================================
% test findSup. comparing the results of findSup with the one calculated
% step by step until the BPL (or FPL) is stable.
%
% There are different test cases.
%
% 05-Dec-2017 author: Yang Cao
%=========================================
addpath('tools/');
%% test case 0 of sup (qArr==dArr)
% n=10;
% m=abs(normrnd(1,1,n,n));
% di=sum(m, 2);
% TM=bsxfun(@rdivide, m, di);
% TM=[TM(1,:); TM(1,:)];
%
% e=1;
%% test case 1 of sup (q~=0/1 d~=0/1)
n=5;
m=abs(normrnd(1,1,n,n));
di=sum(m, 2);
TM=bsxfun(@rdivide, m, di);
e=0.1;
%% test case 2 of sup (d==0, e<log(1/q))
% n=50;
% m=abs(normrnd(1,1,n,n));
% di=sum(m, 2);
% TM=bsxfun(@rdivide, m, di);
%
% TM(1,[1:n-1])=0;
% TM(1,n)=1;
%
% e=0.001;
%% test case 3 of sup (d==0, e>=log(1/q))
% n=4;
% m=abs(normrnd(1,1,n,n));
% di=sum(m, 2);
% TM=bsxfun(@rdivide, m, di);
% TM(1,[1:n-2])=0;
% TM(1,n-1)=0.2;
% TM(1,n)=0.8;
% e=0.314;
%% test case 4 of sup (d==0, q==1)
% n=50;
% m=abs(normrnd(1,1,n,n));
% di=sum(m, 2);
% TM=bsxfun(@rdivide, m, di);
%
% % with element 0
% TM(1,[1:n-1])=0;
% TM(1,n)=1;
% TM(2,[1:n-2])=0;
% TM(2, n-1)=1;
% TM(2,n)=0;
%
% e=1;
%% findSup
a1=0;
an=10;
[EspMatrix, qM, dM, QDplusInd]= preCompQDMatrix(TM);
[aArrMax, qArrMax, dArrMax] = genLFunc(a1, an, EspMatrix, qM, dM);
tic;
% [maxSup, q_sup, d_sup] =findSup(TM, e, [], [], [])
[maxSup, q_sup, d_sup] = findSup(TM, e, qM, dM, QDplusInd)
toc;
% maxSup
% q_sup
% d_sup
%% calc by TM
T=200;
aArr=zeros(1,T);
aArr(1,1) = e;
for i=2:T
% cprintf('blue',['t=',num2str(i),'\n']);
[maxBPL, q, d] = calcPLbyFunc(aArr(1,i-1), aArrMax, qArrMax, dArrMax);
aArr(1,i) = maxBPL+e;
end
aArr(1,T)
% % hold on
% % plot(aArr)