-
Notifications
You must be signed in to change notification settings - Fork 1
/
PS.m
52 lines (51 loc) · 2.41 KB
/
PS.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
function country = PS(country,F)
nF=numel(F);
Dmax = zeros(1, nF);
Dmin = zeros(1, nF);
for k=1:nF
keep = zeros(1,1);
for i = 1 : numel(F{k})
for j = 1 : numel(F{k})
if j ~= i
%A = sqrt((country(F{k}(1,i)).Cost(1) - country(F{k}(1,j)).Cost(1))^2 + (country(F{k}(1,i)).Cost(2) - country(F{k}(1,j)).Cost(2))^2 + (country(F{k}(1,i)).Cost(3) - country(F{k}(1,j)).Cost(3))^2);
A = sqrt((country(F{k}(1,i)).Cost(1) - country(F{k}(1,j)).Cost(1))^2 + (country(F{k}(1,i)).Cost(2) - country(F{k}(1,j)).Cost(2))^2);
keep = [keep; A]; %#ok<*AGROW>
end
end
end
if numel(keep)>1 && keep(1) == 0
keep(1) = [];
else
end
Dmax(k) = max(keep);
Dmin(k) = min(keep);
end
for k=1:nF
for i = 1 : numel(F{k})
NormalizedDistance = 0;
Sum_Distance = 0;
Mu = 0;
for j = 1 : numel(F{k})
if j ~= i
%NormalizedDistance = (sqrt((country(F{k}(1,i)).Cost(1) - country(F{k}(1,j)).Cost(1))^2 + (country(F{k}(1,i)).Cost(2) - country(F{k}(1,j)).Cost(2))^2 + (country(F{k}(1,i)).Cost(3) - country(F{k}(1,j)).Cost(3))^2)) - (Dmax(k)-Dmin(k));
NormalizedDistance = sqrt((country(F{k}(1,i)).Cost(1) - country(F{k}(1,j)).Cost(1))^2 + (country(F{k}(1,i)).Cost(2) - country(F{k}(1,j)).Cost(2))^2);
Sum_Distance = NormalizedDistance + Sum_Distance;
end
end
Mu = Sum_Distance/(numel(F{k})-1);
PenalizationTerm = 0;
for j = 1 : numel(F{k})
if j ~= i
B = (Dmax(k)-Dmin(k))/(sqrt((country(F{k}(1,i)).Cost(1) - country(F{k}(1,j)).Cost(1))^2 + (country(F{k}(1,i)).Cost(2) - country(F{k}(1,j)).Cost(2))^2));
PenalizationTerm = PenalizationTerm + B;
end
end
PM = Mu + PenalizationTerm;
country(F{k}(1,i)).PS = PM + (country(F{k}(1,i)).Rank-1)*numel(country(F{k}(1,i)).Cost);
TT = isnan(country(F{k}(1,i)).PS);
if TT == 1
country(F{k}(1,i)).PS = max(Dmax) + (country(F{k}(1,i)).Rank-1)*numel(country(F{k}(1,i)).Cost);
end
end
end
end