Esempio n. 1
0
        private bool CalculatePcm(double[][] matrix)
        {
            //insertLog("\nENTER FUNC()=> private bool calculatePCM(...)");

            PrioritiesSelector ps        = new PrioritiesSelector();
            GeneralMatrix      oldMatrix = new GeneralMatrix(matrix);
            //for all transposed elements calculate their inverse values
            GeneralMatrix newMatrix = AHPModel.ExpandUtility(oldMatrix);

            ps.ComputePriorities(newMatrix);
            //System.Math.Round(choices.GetElement(0, 0) * 100, 0))
            InsertLog(string.Format("Consistency Ratio: {0}%", System.Math.Round(ps.ConsistencyRatio * 100, 0)));
            //if(ps.ConsistencyRatio == double.NaN)
            return(ps.ConsistencyRatio <= CiAcceptableValue);
        }
Esempio n. 2
0
        public void TestExpansionUtility()
        {
            double[][] mat = new double[][]
            {
                new double[] { 1, 2, 3, 4 },
                new double[] { 0, 1, 2, 5 },
                new double[] { 0, 0, 1, 5 },
                new double[] { 0, 0, 0, 1 }
            };
            GeneralMatrix oldMatrix = new GeneralMatrix(mat);

            GeneralMatrix newMatrix = AHPModel.ExpandUtility(oldMatrix);

            Assert.AreEqual(newMatrix.GetElement(1, 0), 0.5);
            double val = 1.0 / 3.0;

            Assert.AreEqual(newMatrix.GetElement(2, 0), val);
            Assert.AreEqual(newMatrix.GetElement(3, 0), 0.25);
        }
Esempio n. 3
0
        public void TestChoiceMatrix()
        {
            double[][] mat1 = new double[][]
            {
                new double[] { 1, 2, 3, 4 },
                new double[] { 0, 1, 2, 5 },
                new double[] { 0, 0, 1, 5 },
                new double[] { 0, 0, 0, 1 }
            };

            GeneralMatrix gmat1 = new GeneralMatrix(mat1);

            gmat1 = AHPModel.ExpandUtility(gmat1);

            double[][] mat2 = new double[][]
            {
                new double[] { 1, 2, 3, 1 },
                new double[] { 0, 1, 2, 3 },
                new double[] { 0, 0, 1, 9 },
                new double[] { 0, 0, 0, 1 }
            };
            GeneralMatrix gmat2 = new GeneralMatrix(mat2);

            gmat2 = AHPModel.ExpandUtility(gmat2);

            double[][] mat3 = new double[][]
            {
                new double[] { 1, 4, 2, 2 },
                new double[] { 0, 1, 2, 4 },
                new double[] { 0, 0, 1, 4 },
                new double[] { 0, 0, 0, 1 }
            };

            GeneralMatrix gmat3 = new GeneralMatrix(mat3);

            gmat3 = AHPModel.ExpandUtility(gmat3);


            //3 criteria 4 choices
            AHPModel model = new AHPModel(3, 4);

            model.AddCriterionRatedChoices(0, mat1);
            model.AddCriterionRatedChoices(1, mat2);
            model.AddCriterionRatedChoices(2, mat3);

            GeneralMatrix matrix = model.ChoiceMatrix;

            GeneralMatrix nmat1 = matrix.GetMatrix(0, 3, 0, 3);
            GeneralMatrix nmat2 = matrix.GetMatrix(0, 3, 4, 7);
            GeneralMatrix nmat3 = matrix.GetMatrix(0, 3, 8, 11);

            bool alarm = false;

            int i, j;

            for (i = 0; i < nmat1.ColumnDimension; i++)
            {
                for (j = 0; j < nmat1.RowDimension; j++)
                {
                    if (nmat1.GetElement(i, j) != gmat1.GetElement(i, j))
                    {
                        alarm = true;
                    }
                }
            }

            for (i = 0; i < nmat2.ColumnDimension; i++)
            {
                for (j = 0; j < nmat2.RowDimension; j++)
                {
                    if (nmat2.GetElement(i, j) != gmat2.GetElement(i, j))
                    {
                        alarm = true;
                    }
                }
            }

            for (i = 0; i < nmat3.ColumnDimension; i++)
            {
                for (j = 0; j < nmat3.RowDimension; j++)
                {
                    if (nmat3.GetElement(i, j) != gmat3.GetElement(i, j))
                    {
                        alarm = true;
                    }
                }
            }


            Assert.IsFalse(alarm);
        }