Ejemplo n.º 1
0
        private static DataArray <string> IncidenceMatrixWithCalcuationsToDataArray(IncidenceMatrix <Goal> matrix)
        {
            var matrixLength            = matrix.Variables.Length;
            var dataArray               = new DataArray <string>(matrixLength + 3, matrixLength + 3);
            var data                    = matrix.ToInt32Array();
            var numberOfAncestors       = matrix.GetNumberOfAncestorsForEachVariable().Values.ToArray();
            var numberOfDescendants     = matrix.GetNumberOfDescendantsForEachVariable().Values.ToArray();
            var prioritiesOfAncestors   = matrix.GetPrioritiesByAncestorsForEachVariable().Values.ToArray();
            var prioritiesOfDescendants = matrix.GetPrioritiesByDescendantsForEachVariable().Values.ToArray();

            for (int i = 1; i < matrixLength + 1; i++)
            {
                dataArray[i][0] = dataArray[0][i] = matrix.Variables[i - 1].Index.ToString();
                for (int j = 1; j < matrixLength + 1; j++)
                {
                    dataArray[i][j] = data[i - 1, j - 1].ToString();
                }
                dataArray[matrixLength + 1][i] = numberOfDescendants[i - 1].ToString();
                dataArray[i][matrixLength + 1] = numberOfAncestors[i - 1].ToString();
                dataArray[matrixLength + 1][matrixLength + 1] = numberOfDescendants.Sum().ToString();
                dataArray[matrixLength + 2][i] = prioritiesOfDescendants[i - 1].ToString();
                dataArray[i][matrixLength + 2] = prioritiesOfAncestors[i - 1].ToString();
            }
            return(dataArray);
        }