public static void AhpModelTest() { //构造第一层 IList<Factor> factors1 = new List<Factor>() { new Factor("Z") }; Level level1 = new Level(null, factors1, null, null); AhpModel ahpModel = new AhpModel(level1); //构造第二层 //第二层因素 IList<Factor> factors2 = new List<Factor> { new Factor("A1"), new Factor("A2"), new Factor("A3"), new Factor("A4"), new Factor("A") }; //第二层关系矩阵 Matrix level2Relation = new Matrix(5, 1); level2Relation.InsertDataFromList(new List<double> { 1, 1, 1, 1, 1 }); //第二层判断矩阵 JudgeMatrix level2JudugeMatrix1 = new JudgeMatrix(5); level2JudugeMatrix1.InsertDataFromList(new List<double> { 1, 1/2.0, 4, 3, 3, 2, 1, 7, 5, 5, 1/4, 1/7, 1, 1/2.0, 1/3.0, 1/3.0, 1/5.0, 2, 1, 1, 1/3.0, 1/5.0, 3, 1, 1 }); //加入到判断矩阵序列 Dictionary<Factor, JudgeMatrix> level2Judges = new Dictionary<Factor, JudgeMatrix>(); level2Judges.Add(level1.Factors[0], level2JudugeMatrix1); Level level2 = new Level(level1, factors2, level2Relation, level2Judges); //加入到模型中 ahpModel.PushLevel(level2); //构造第三层次 IList<Factor> factors3 = new List<Factor> { new Factor("B1"), new Factor("B2"), new Factor("B3"), }; //第三层关系矩阵 Matrix level3Relation = new Matrix(3, 5); level3Relation.InsertDataFromList(new List<double> { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); //第三层判断矩阵 JudgeMatrix level3JudugeMatrix1 = new JudgeMatrix(3); level3JudugeMatrix1.InsertDataFromList(new List<double> { 1, 2, 5, 1/2.0, 1, 2, 1/5.0, 1/2.0, 1 }); JudgeMatrix level3JudugeMatrix2 = new JudgeMatrix(3); level3JudugeMatrix2.InsertDataFromList(new List<double> { 1, 1/3.0, 1/8.0, 3, 1, 1/3.0, 8, 3, 1 }); JudgeMatrix level3JudugeMatrix3 = new JudgeMatrix(3); level3JudugeMatrix3.InsertDataFromList(new List<double> { 1, 1, 3, 1, 1, 3, 1/3.0, 1/3.0, 1 }); JudgeMatrix level3JudugeMatrix4 = new JudgeMatrix(3); level3JudugeMatrix4.InsertDataFromList(new List<double> { 1, 3, 4, 1/3.0, 1, 1, 1/4.0, 1, 1 }); JudgeMatrix level3JudugeMatrix5 = new JudgeMatrix(3); level3JudugeMatrix5.InsertDataFromList(new List<double> { 1, 1, 1/4.0, 1, 1, 1/4.0, 4, 4, 1 }); //加入到判断矩阵序列 Dictionary<Factor, JudgeMatrix> level3Judges = new Dictionary<Factor, JudgeMatrix>(); level3Judges.Add(level2.Factors[0], level3JudugeMatrix1); level3Judges.Add(level2.Factors[1], level3JudugeMatrix2); level3Judges.Add(level2.Factors[2], level3JudugeMatrix3); level3Judges.Add(level2.Factors[3], level3JudugeMatrix4); level3Judges.Add(level2.Factors[4], level3JudugeMatrix5); Level level3 = new Level(level2, factors3, level3Relation, level3Judges); //加入到模型中 ahpModel.PushLevel(level3); //测试数据 ahpModel.GetLevelInfo(3).GetTotalWeightVect().DisplayMatrix(DataHelper.ConsoloOutput); }
public static void JudgeMatrixTest() { JudgeMatrix jm1 = new JudgeMatrix(5, "测试矩阵"); jm1.InsertDataFromList( new List<double> { 1, 0.5, 4, 3, 3, 2, 1, 7, 5, 5, 1/4.0, 1/7.0, 1, 1/2.0, 1/3.0, 1/3.0, 1/5.0, 2, 1, 1, 1/3.0, 1/5.0, 3, 1, 1 }); jm1.DisplayMatrix(DataHelper.ConsoloOutput); double eiginValue; var vect1 = jm1.SingleFactorWightVect(out eiginValue); vect1.DisplayMatrix(DataHelper.ConsoloOutput); Console.WriteLine("测试矩阵的\n特征值={3},\nCI={0},\nRI={1},\nCR={2}", jm1.CI, jm1.RI, jm1.CR, eiginValue); }