Skip to content

Commit e010823

Browse files
committed
adding all files from local
1 parent 3f4a7e5 commit e010823

File tree

462 files changed

+62838
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

462 files changed

+62838
-0
lines changed

BuildStochasticMatrix.m

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
function M = BuildStochasticMatrix(opt, population)
2+
3+
4+
switch(opt.UtilityOption)
5+
case 1
6+
n = size(population,1);%size of population;
7+
M = sparse(n, n);%large sqaure matrix
8+
u = computeUtility1(population);%suppose this is L1-norm
9+
10+
for i = 1:n
11+
for j = 1:n
12+
if(i~=j)
13+
if u(i)>u(j)
14+
M(j, i) = u(i) - u(j);%direction from (i) to (j)
15+
elseif u(i)<u(j)
16+
M(i, j) = u(j) - u(i);
17+
end
18+
end
19+
end
20+
end
21+
22+
%normalize to make stochastic
23+
for i = 1:n
24+
M(:,i) = M(:,i)./sum(M(:,i));
25+
end
26+
27+
case 2
28+
n = size(population,1);%size of population
29+
M = sparse(n, n);%declare a sparse matrix
30+
Mdl = KDTreeSearcher(population,'Distance','euclidean');
31+
u = computeUtility1(population);%suppose this is L1-norm
32+
d = size(population,2);
33+
[Idx,~] = knnsearch(Mdl,population,'K',d+1);%k-d tree
34+
for i = 1:n
35+
for j = 2:d+1 %1st member is itself
36+
s = Idx(j);
37+
if(i~=s)
38+
if u(i)>u(s)
39+
%direction from (i) to (j), value iteration is reverse, it takes indegree
40+
%rather than outdegree
41+
M(s, i) = u(i) - u(s);
42+
elseif u(i)<u(s)
43+
M(i, s) = u(s) - u(i);
44+
end
45+
end
46+
end
47+
end
48+
49+
%normalize M to make column stochastic
50+
for i = 1:n
51+
M(:,i) = M(:,i)./sum(M(:,i));
52+
end
53+
54+
otherwise
55+
56+
57+
end
58+
59+
end
60+
61+
function u = computeUtility1(population)
62+
u = sum(population,2); %should be normalized ---- %%sum(population.*0.5,2);
63+
end

GD/.IGD.2D.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
136.0000000000 4.0000000000
2+
126.6304000000 4.0576000000
3+
117.0000000000 4.2500000000
4+
107.2336000000 4.6084000000
5+
96.8400000000 5.2100000000
6+
86.4100000000 6.1025000000
7+
75.4384000000 7.4596000000
8+
64.9800000000 9.2450000000
9+
55.3352000000 11.2338000000
10+
45.6968000000 13.6242000000
11+
36.6368000000 16.3592000000
12+
28.5768000000 19.3442000000
13+
21.2552000000 22.7138000000
14+
15.2352000000 26.2088000000
15+
10.5800000000 29.6450000000
16+
6.7712000000 33.2928000000
17+
4.0328000000 36.8082000000
18+
2.0808000000 40.3202000000
19+
0.8712000000 43.6178000000
20+
0.2048000000 46.8512000000
21+
0.0000000000 50.0000000000

0 commit comments

Comments
 (0)