-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.m
109 lines (84 loc) · 2.42 KB
/
example.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
99
100
101
102
103
104
105
106
107
function example()
%Launch BRWWR on a small example
n = 30;
A = ones(n,n);
%Cinit = [1, 1, 1, 1, 3, 1, 1, 1, 1];
%Cinit = [1,2,3
% 4,5,6];
%1 Matrix 1 (Gaussian obstacle)
%Cinit = gauss2d(A, 3, [15,15]);
%Cinit = reshape(Cinit.*5', 1,n*n);
Cinit = ones(n);
Cinit(1:20, 10) = 5;
Cinit(10:30, 20) = 5;
Cinit = reshape(Cinit', 1,n*n);
%Cinit = [1, 1, 1, 1, 1, 1, 1, 1, 1
% 1, 1, 1, 1, 1, 1, 1, 1, 1
% 1, 1, 1, 1, 1, 1, 1, 1, 1
% 1, 2, 2, 2, 1, 2, 2, 2, 1
% 1, 2, 3, 2, 1, 2, 3, 2, 1
% 1, 2, 2, 2, 1, 2, 2, 2, 1
% 1, 1, 1, 1, 1, 1, 1, 1, 1
% 1, 1, 1, 1, 1, 1, 1, 1, 1
% 1, 1, 1, 1, 1, 1, 1, 1, 1];
%Cinit = reshape(Cinit', 1,n*n);
%Cinit = [1, 1, 1, 3, 1, 1, 1, 1, 1
% 1, 1, 1, 3, 1, 1, 1, 1, 1
% 1, 1, 1, 3, 1, 1, 1, 1, 1
% 1, 1, 1, 3, 1, 1, 1, 1, 1
% 1, 1, 1, 3, 1, 1, 1, 1, 1
% 1, 1, 1, 3, 1, 1, 3, 1, 1
% 1, 1, 1, 1, 1, 1, 3, 1, 1
% 1, 1, 1, 1, 1, 1, 3, 1, 1
% 1, 1, 1, 1, 1, 1, 3, 1, 1];
%Cinit = reshape(Cinit', 1,n*n);
%Cinit = [1, 1, 1, 1, 1, 1, 1, 1, 1
% 1, 1, 1, 1, 1, 1, 1, 1, 1
% 1, 1, 5, 1, 1, 1, 1, 1, 1
% 1, 1, 1, 1, 1, 1, 1, 1, 1
% 1, 1, 1, 1, 1, 1, 1, 1, 1
% 1, 1, 1, 1, 1, 5, 5, 5, 5
% 1, 1, 1, 1, 1, 5, 5, 5, 5
% 1, 1, 1, 1, 1, 5, 5, 5, 5
% 1, 1, 1, 1, 1, 5, 5, 5, 5];
%Cinit = reshape(Cinit', 1,n*n);
C = ones(n*n, 1) * Cinit;
%Compute Markov chain transition matrix
M = Adj2Markov(A);
M = AtoP(M);
%M = costToPtrans01(ones(n*n,n*n),1000000 * realmin);
%Computation of Markov chain transition probability matrix
%nM = size(C,1)^2;
%MA = zeros(nM,nM);
%for i=1:nM;
% for j=1:nM;
% if (abs(mod(i,nM) - mod(j,nM)) == 1)
% MA(i,j) = 1;
% else
% MA(i,j) = 0;
% end
% end
%end
P = BRWWR(M, C, 0.1);
%Stationary disctribution of Pref
[Vl,Dl] = eig(M.');
PrefStat = reshape(-Vl(:,1), n,n)';
%Stationary distribution of BRWWR P
[Vl,Dl] = eig(P.');
PStat = reshape(Vl(:,1), n,n)';
h = figure;
%subplot(2,2,1);
%imagesc(A);
%colorbar;
%subplot(2,2,2);
imagesc(reshape(Cinit, n, n)');
colorbar;
print(h, '-dpdf', 'A.pdf')
%subplot(2,2,3);
%imagesc(PrefStat);
%colorbar;
j = figure;
%subplot(2,2,4);
imagesc(abs(PStat));
colorbar;
print(j, '-dpdf', 'B.pdf');