1.构建层次结构模型构建成对比较矩阵不一致性检验(程序可进行一致性检验。。。略)2.实际问题解决 关于Bn是B1,B2,B2对An的权重(Bn与B1,B2,B2,不是一个意思。。。。。。可求对sum(Bi*An)(i...n)目标的权重)
%层次分析法(AHP)
disp('请输入判断矩阵A(n阶)');
A = input('A=');
[n,n] = size(A);
x = ones(n,100);
y = ones(n,100);
m = zeros(1,100);
m(1) = max(x(:,1));
y(:,1) = x(:,1);
x(:,2) = A*y(:,1);
m(2) = max(x(:,2));
y(:,2) = x(:,2)/m(2);
p=0.0001; i=2; k=abs(m(2)-m(1));
while k>p
i=i+1;
x(:,i) = A*y(:,i-1);
m(i) = max(x(:,i));
y(:,i) = x(:,i)/m(i);
k=abs(m(i)-m(i-1));
end
a = sum(y(:,i));
w = y(:,i)/a;
t = m(i);
disp(w);
%一致性检验
CI = (t-n)/(n-1);
RI = [0 0 0.52 0.89 1.12 1.36 1.41 1.46 1.49 1.52 1.54 1.56 1.58 1.59];
CR = CI/RI(n);
if CR<0.10
disp('此矩阵一致性可以接受!');
disp('CI=');disp(CI);
disp('CR=');disp(CR);
end
|