• AHP(使用于某项目设备重要度评估测试)


    用层次法和蒙特卡洛模型计算权重系数,然后建立判断矩阵进行随机一致性检验,最后求出重要度指数。

     1  string calculateStr = "1,2,3,2,1,|1,2,3,2,1,|1,2,3,2,1,|1,2,3,2,1,";
     2             var vals = calculateStr.Split('|');
     3             var Strlen = vals.Length - 1;
     4             double[,] t = new double[Strlen, Strlen];
     5             double RI = 0;
     6             for (int i = 0; i < Strlen; i++)
     7             {
     8                 for (int j = 0; j < Strlen; j++)
     9                 {
    10                     t[i, j] = double.Parse(vals[i].Split(',')[j]);
    11                 }
    12             }
    13 
    14             double result = 0;
    15             int len = t.GetUpperBound(0) + 1;
    16             double[,] t1 = new double[len, len];
    17             double[] dNums = new double[len];
    18             for (int i = 0; i < len; i++)
    19             {
    20                 double colResut = 0;
    21                 for (int j = 0; j < len; j++)
    22                 {
    23                     colResut += t[j, i];
    24                 }
    25                 for (int k = 0; k < len; k++)
    26                 {
    27                     t1[k, i] = Sum(t[k, i], colResut);
    28                 }
    29             }
    30 
    31             for (int i = 0; i < len; i++)
    32             {
    33                 double vector = 0;
    34                 double colResult = 0;
    35 
    36                 for (int j = 0; j < len; j++)
    37                 {
    38                     colResult += t[j, i];
    39                 }
    40 
    41                 for (int r = 0; r < len; r++)
    42                 {
    43                     vector += t1[i, r];
    44                 }
    45                 dNums[i] = vector / len;
    46                 result += colResult * vector / len;
    47             }
    48 
    49 
    50             if (len > 2)
    51             {
    52                 switch (len)
    53                 {
    54                     case 3:
    55                         RI = 0.58;
    56                         break;
    57                     case 4:
    58                         RI = 0.9;
    59                         break;
    60                     case 5:
    61                         RI = 1.12;
    62                         break;
    63                     case 6:
    64                         RI = 1.24;
    65                         break;
    66                     case 7:
    67                         RI = 1.32;
    68                         break;
    69                     case 8:
    70                         RI = 1.41;
    71                         break;
    72                     case 9:
    73                         RI = 1.46;
    74                         break;
    75                 }
    76             }
    77 
    78             var CI = (result - len) / (len - 1);
    79             var CR = CI / RI;
    80             Console.WriteLine(CR);
    控制台代码
    好好学习,天天向上。
  • 相关阅读:
    IOS 两种控制器的使用,纯代码UITabBarController 与 UINavigationController
    iOS UI控件总结(全)
    IOS 参数string 转成url
    CocoaPods 的使用与一些异常情况的处理
    创建自己的 FrameWork(含demo)-Xcode7环境
    UITextView 一些属性的设置
    跳转第二弹
    iOS--登录注册页面-趣享-接口设计
    《大道至简》第一章阅读笔记
    软件工程个人作业02
  • 原文地址:https://www.cnblogs.com/Zhengxue/p/8777839.html
Copyright © 2020-2023  润新知