📄 ahpcalc.m
字号:
function [finalrank,rank,rc]=ahpcalc(order,altvcriteria,critvcriteria)
%AHPCALC Perform a complete AHP calculation
% [FINALRANK,RANK,RC]=AHPCALC(ORDER,ALTVCRITERIA,CRITVCRITERIA)
%
% For N alternatives and M criteria for ranking:
%
% ORDER is a matrix with M rows and N columns.
% The elements of the I_th row are the integers 1 to N,
% indexing the alternatives in descending order of preference
% with respect to criterion I.
%
% ALTVCRITERIA is a matrix with M rows and N*(N-1)/2 columns.
% The I_th row contains the upper triangular entries of the AHP
% reciprocal matrix ranking the N alternatives with respect to
% criterion I, in the descending order of preference indicated
% in the I_th row of ORDER.
%
% CRITVCRITERIA may be a vector of length M*(M-1)/2 giving the
% upper triangular entries of the AHP reciprocal matrix
% comparing the criteria, or it may be a normalized vector of
% length M giving the AHP vector weighting the criteria.
%
% FINALRANK is a normalized vector of length N giving the overall
% ranking of the alternatives.
%
% The rows of RANK give the ranking of the alternatives with
% respect to the individual attributes.
%
% RC is the vector giving the normalized weights of the
% criteria. Note that if CRITVCRITERIA is specified as a
% normalized vector, then RC=CRITVCRITERIA
%
% Copyright (C) 2001 Michael J. Scott
ordersize = size(order);
avcsize = size(altvcriteria);
cvcsize = size(critvcriteria);
if ordersize(1) ~= avcsize(1)
disp 'ORDER and ALTVCRITERIA must have same number of rows.';
disp 'Exiting.';
return;
end
if (ordersize(2)*(ordersize(2)-1)/2) ~= avcsize(2)
disp 'Alternative comparisons of wrong order.';
disp 'Exiting.';
return;
end
% If the criteria comparison is already an appropriate normalized
% vector, then use it.
if (cvcsize(2) == ordersize(1))
if (sum(critvcriteria) <2)
rc = critvcriteria';
end
else %otherwise calculate the normalized vector
if (ordersize(1)*(ordersize(1)-1)/2) ~= cvcsize(2)
disp 'Attribute comparisons of wrong order.';
disp 'Exiting.';
return;
end
critmat = ahpmakemat(critvcriteria);
[rc,cc] = ahpvector(critmat);
if cc > 0.1
s=sprintf(' C.R.=%.3f from criteria-criteria comparisons',cc);
disp([s]);
end
end
for i=1:ordersize(1)
amat = ahpmakemat(altvcriteria(i,:));
[ra,ca] = ahpvector(amat);
if ca > 0.1
s= sprintf(' C.R.=%.3f from comparing alternatives on criterion %d',ca,i);
disp([s]);
end
rank(i,:)=ahpreorder(order(i,:),ra);
end
finalrank = rank'*rc;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -