-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPartitionSL.m
More file actions
142 lines (137 loc) · 2.72 KB
/
Copy pathPartitionSL.m
File metadata and controls
142 lines (137 loc) · 2.72 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
function pS=PartitionSL(S,cs,n)
% PARTITIONSL determines a partition of S w.r.t.
% a communication situation.
%
% Usage: pS=PartitionSL(S,cs,n)
%
% Define variables:
% output:
% pS -- Partition of S w.r.t cs.
%
% input:
% S -- A coalition S (Integer).
% cs -- A communication situation like [3 5 6]
% for {[1,2],[1 3],[2 3]}. Other structures induces
% failures.
% n -- Number of players involved (Integer).
%
% Author: Holger I. Meinhardt (hme)
% E-Mail: Holger.Meinhardt@wiwi.uni-karlsruhe.de
% Institution: University of Karlsruhe (KIT)
%
% Record of revisions:
% Date Version Programmer
% ====================================================
% 07/21/2013 0.4 hme
%
J=1:n;
pl=2.^(J-1);
pS=[];
int=0:-1:1-n;
piS=zeros(1,n);
csm=pl(rem(floor(S(:)*pow2(int)),2)==1);
ca=bitand(S,cs);
rc=ca;
for k=1:n
ica=unique(ca(ca==pl(k)));
rc(rc==pl(k))=[];
if isempty(ica)~=1
piS(k)=ica;
end
end
piS=piS(piS>0);
lpi=length(piS);
lrc=length(rc);
if lrc > 1
rc2=rc;
st=1;
e2=0;
for ii=1:lrc-1
rc2(1:ii)=[];
lr2=length(rc2);
e2=e2+lr2;
ba(st:e2)=bitand(rc(ii),rc2);
rc2=rc;
st=e2+1;
end
else
if rc < S
csm2=pl(rem(floor(rc(:)*pow2(int)),2)==1);
piS=setdiff(csm,csm2);
lpi=length(piS);
ba=0;
else
ba=0;
end
end
idx=1;
for m=1:lpi
imQ=(ba==piS(m));
if any(imQ)
isp=[];
else
isp(idx)=piS(m);
idx=idx+1;
end
end
if all(piS==0)
isp=[];
end
if all(ba==0)
if rc~=0
rc(rc==0)=[];
if isempty(rc)~=1
lp=length(piS);
if lp >= 1
for p=1:lp
nisQ1=any(bitor(piS(p),rc)==rc);
if nisQ1==1
piS(p)=0;
end
end
piS(piS==0)=[];
pS=[piS rc];
else
pS=rc;
end
end
elseif rc==0
if lpi==1
pS=csm;
else
pS=piS;
end
else
rc(rc==0)=[];
if isempty(rc)~=1
lp=length(piS);
if lp >= 1
for j=1:lp
nisQ2=any(bitor(piS(j),rc)==rc);
if nisQ2==1
piS(j)=0;
end
end
piS(piS==0)=[];
pS=[piS rc];
else
pS=[piS rc];
end
else
pS=csm;
end
end
else
cf=rc(1);
for l=2:lrc
cf=bitor(cf,rc(l));
end
fid=find(bitor(isp,cf)==S);
isp(fid)=[];
if cf~=S
pS=[cf,S-cf];
else
pS=sort([isp cf]);
end
end
pS=unique(pS);