Skip to content

Commit c2db8ec

Browse files
authored
Add files via upload
1 parent 839274b commit c2db8ec

File tree

9 files changed

+137
-0
lines changed

9 files changed

+137
-0
lines changed

Mainfile.m

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
% Mainfiles purpose is to show how to use n-ary TOPSIS method
2+
% that uses n-ary norm operators to set preference for either positive
3+
% ideal solution or negative ideal solution depending on the practical
4+
% problem. It was published in
5+
6+
% P. Luukka, N—ary norm operators and TOPSIS, 2020 IEEE International
7+
% Conference on Fuzzy Systems (FUZZ-IEEE), Glasgow, UK, 2020, pp. 1-6,
8+
% doi: 10.1109/FUZZ48607.2020.9177580.
9+
10+
11+
%First lets create artificial data of ten alternatives and five criteria:
12+
c=10;
13+
data=c*randn(10,5);
14+
%Define parameters p for Minkowski metric (1=Manhattan distance,2=Euclidean distance etc)
15+
%and parameter values for fuzzy union (w) and intersection (w2) operators
16+
p=1; w=2; w2=5;
17+
%See more information about these from the proceedings.
18+
19+
%Define whether criteria is benefit criteria or cost criteria in crit
20+
%vector 1=benefit, 2=cost.
21+
crit=[1 1 1 2 1]; %in this example fourth would be cost criteria and others benefit
22+
23+
[cc,PISB,NISB]=narytopsis(data,p,w,w2,crit)
24+
25+
%For output of the function you get:
26+
%cc = closeness coefficient values for ten alternatives
27+
%PISB = distance to positive ideal solution
28+
%NISB = distance to negative ideal solution
29+
30+
%You can get the ordering of the alternatives by sorting CC to descending order
31+
[Y,I]=sort(cc,'descend');
32+
33+
%Order of the attributes:
34+
Order=I'

distM.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function d=distM(x,y,p)
2+
[m,n]=size(x);
3+
d=1/n*(sum(abs(x-y ).^p).^(1/p));

i_yager.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
function mu=i_bd(a,b,w)
2+
mu=1-min([1,((1-a)^w+(1-b)^w)^(1/w)]);

narytopsis.m

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function [c,Dplus,Dminus]=topsis(data,p,w,w2,crit)
2+
x=data;
3+
[m,n]=size(x);
4+
a=zeros(m,n);
5+
%Normalization to unit interval:
6+
a=normalization(x);
7+
8+
%Positive and negative ideal solutions:
9+
PIS=zeros(1,n);
10+
NIS=zeros(1,n);
11+
for j=1:n
12+
if crit(j)==1
13+
PIS(j)=recursivetconorm(a(:,j)',w);
14+
NIS(j)=recursivetnorm(a(:,j),w2);
15+
else
16+
NIS(j)=recursivetconorm(a(:,j)',w);
17+
PIS(j)=recursivetnorm(a(:,j),w2);
18+
end
19+
end
20+
21+
%Distances to PIS and NIS
22+
DPISB=zeros(1,m);
23+
DNISB=zeros(1,m);
24+
for i=1:m
25+
Dplus(i)=distM(PIS,a(i,:),p);
26+
Dminus(i)=distM(NIS,a(i,:),p);
27+
end
28+
%Closeness coefficient:
29+
c=zeros(1,m);
30+
for i=1:m
31+
c(i)=Dminus(i)/(Dplus(i)+Dminus(i));
32+
end

normalization.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function data_v=normalization2(data)
2+
%scaling data between [0,1]
3+
[m,n]=size(data);
4+
data_v=data;
5+
mins_v = min(data_v);
6+
Ones = ones(size(data_v));
7+
data_v = data_v+Ones*diag(abs(mins_v));
8+
maxs_v = max(data_v);
9+
data_v = data_v*diag(maxs_v.^(-1));

recursivetconorm.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function unorm=tconormstandardn(A,w)
2+
[n,m]=size(A);
3+
unorm=u_yager(A(1),A(2),w);
4+
for i=2:n
5+
unorm=u_yager(A(i),unorm,w);
6+
end

recursivetnorm.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function inorm=tnormstandardn(A,w)
2+
[n,m]=size(A);
3+
inorm=i_yager(A(1),A(2),w);
4+
for i=2:n
5+
inorm=i_yager(A(i),inorm,w);
6+
end

topsisdistpnary.m

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
function [c,Dplus,Dminus,PIS,NIS,a]=topsis(data,p,w)
2+
x=data;
3+
[m,n]=size(x);
4+
a=zeros(m,n);
5+
%Normalization:
6+
a=normalization2(x);
7+
8+
%Positive and negative ideal solutions:
9+
PIS=zeros(1,n);
10+
NIS=zeros(1,n);
11+
w2=2;
12+
for j=1:n
13+
% PIS(j)=max(a(:,j));
14+
% NIS(j)=min(a(:,j));
15+
% PIS(j)=tconormstandardn(a(:,j));
16+
% PIS(j)=tconormprob(a(:,j)');
17+
% PIS(j)=tconormluka(a(:,j)');
18+
% PIS(j)=tconormdrastic(a(:,j)');
19+
PIS(j)=recursivetconorm(a(:,j)',w);
20+
21+
NIS(j)=recursivetnorm(a(:,j),w2);
22+
% NIS(j)=tnormstandardn(a(:,j));
23+
% NIS(j)=tnormprob(a(:,j)');
24+
% NIS(j)=tnormluka(a(:,j)');
25+
end
26+
27+
%Distances to PIS and NIS
28+
DPISB=zeros(1,m);
29+
DNISB=zeros(1,m);
30+
% m1=1;
31+
% q=1;
32+
%p=2;
33+
for i=1:m
34+
Dplus(i)=distM(PIS,a(i,:),p);
35+
Dminus(i)=distM(NIS,a(i,:),p);
36+
end
37+
%Closeness coefficient:
38+
c=zeros(1,m);
39+
for i=1:m
40+
% c(i)=DNIS(i)/(DPIS(i)+DNIS(i));
41+
c(i)=Dminus(i)/(Dplus(i)+Dminus(i));
42+
end

u_yager.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function mu=u_Yager(a,b,w)
2+
3+
mu=min([1,(a^w+b^w)^(1/w)]);

0 commit comments

Comments
 (0)