Пример #1
0
        private string GenerateReport()
        {
            StringBuilder ReportStr = new StringBuilder();

            string[,] currentMatrix;
            double[]       WeightVector;
            MatrixOperater matrixOperater   = new MatrixOperater();
            Hashtable      AllFactorWeights = new Hashtable();                           //存储所有的权重

            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); //新建计时停表
            stopwatch.Restart();

            if (checkMarix(ShowResultOrNot: false) == true)
            {
                ReportStr.Append("Matrix check pass.\r\n\r\n");
                for (int MatrixIndex = 1; MatrixIndex < MatrixList.Count; MatrixIndex++)
                {
                    currentMatrix = (string[, ])MatrixList[MatrixIndex];
                    //输出该层因素
                    ReportStr.Append("    "); //左上角表格留空
                    for (int i = 0; i < currentMatrix.GetLength(0); i++)
                    {
                        ReportStr.Append(((TreeNodeCollection)LayerList[MatrixIndex])[i].Text + " ");
                    }
                    //换行
                    ReportStr.Append("\r\n");
                    //输出矩阵权重
                    ReportStr.Append("W" + MatrixIndex.ToString() + " ");
                    WeightVector = matrixOperater.GetEigenvectorOfMatrix(
                        matrixOperater.conventStringMatrixIntoNumberArray(
                            currentMatrix
                            )
                        );
                    for (int i = 0; i < WeightVector.Length; i++)
                    {
                        ReportStr.Append(Math.Round(WeightVector[i], 4).ToString() + " ");
                        AllFactorWeights.Add(((TreeNodeCollection)LayerList[MatrixIndex])[i].Text, WeightVector[i]);  //把得到的权重存起来
                    }
                    //换行
                    ReportStr.Append("\r\n");
                    //输出分隔符
                    ReportStr.Append("------------------------------------------------\r\n");
                }

                //输出层次总排序
                ReportStr.Append("\r\nTotal sorting weights:\r\n");
                Hashtable totalSortingHashtable = GetTotalSortingWeightVector(AllFactorWeights);
                foreach (string factor in totalSortingHashtable.Keys)
                {
                    ReportStr.Append(factor + ": " + totalSortingHashtable[factor].ToString() + "\r\n");
                }

                ReportStr.Append("------------------------------------------------\r\n");
                stopwatch.Stop();
                ReportStr.Append("Checking finish in " + stopwatch.Elapsed.TotalMilliseconds.ToString() + "ms.\r\n");
            }
            else
            {
                ReportStr.Append("Matrix check not pass!");
            }
            return(ReportStr.ToString());
        }