Beispiel #1
0
        //quoted from options.cs for future use

        /*     protected double GetRealDensity(double density, int year, string m)
         * {
         *    if (density == -2.0)
         *        return Algorithms.MaxValue<double>(mTable[m]);
         *    if (density == -1.0)
         *        if (!densityVector.ContainsKey(year))
         *            throw new Exception("Cannot use density vector for year " + year.ToString());
         *        else
         *            return densityVector[year];
         *    return density;
         * }
         *
         *
         * public double GetSYSIN(bool zeroDiagonal, double maxik, int year, int reachMatrixCount)
         * {
         *    maxik = GetRealDensity(maxik, year, "Data");
         *    double SYSIN = 0.0;
         *
         *    int N = mTable["Data"].Rows;
         *
         *    if (!mTable.ContainsKey("Dependency"))
         *        return 0.0;
         *
         *    if (!zeroDiagonal)
         *    {
         *        for (int i = 0; i < N; ++i)
         *        {
         *            for (int j = 0; j < N; ++j)
         *            {
         *                SYSIN += mTable["Dependency"][i, j];
         *            }
         *        }
         *        SYSIN *= (1 - maxik * N);
         *        SYSIN /= maxik;
         *        SYSIN /= (1 - Math.Pow(maxik * N, reachMatrixCount));
         *    }
         *    else
         *    {
         *        for (int i = 0; i < N; ++i)
         *        {
         *            for (int j = 0; j < N; ++j)
         *            {
         *                SYSIN += mTable["Dependency"][i, j];
         *            }
         *            SYSIN -= mTable["Dependency"][i, i];
         *        }
         *        SYSIN *= (1 - maxik * (N - 1));
         *        SYSIN /= maxik * (N - 1);
         *        SYSIN /= (1 - Math.Pow(maxik * (N - 1), reachMatrixCount));
         *    }
         *
         *    return SYSIN;
         * }
         */

        private double calculate_NPOL(Matrices.Matrix M, List <clique> Cliques)
        {
            double npol;
            int    total_sum = 0, col_sum;

            for (int i = 0; i < Cliques.Count; i++)
            {
                col_sum = 0;
                for (int j = 0; j < M.Rows; j++)
                {
                    if (Cliques[i][j] == 1)
                    {
                        col_sum++;
                    }
                }
                total_sum += col_sum * (M.Rows - col_sum);
            }

            double first_term;

            if (M.Rows % 2 == 0)
            {
                first_term = 4.0 / (double)(Cliques.Count * M.Rows * M.Rows);
            }
            else
            {
                first_term = 4.0 / (double)(Cliques.Count * (M.Rows * M.Rows - 1));
            }

            npol = first_term * total_sum;
            return(npol);
        }
Beispiel #2
0
        private double calculate_InterdependenceSameWeight(List <Matrices.Matrix> list)  //only for first-order dependency, e.g. reachmatrixcount = 1; otherwise for third or more order, need to run dependency matrix alg
        {
            Matrices.Matrix temp = new Matrices.Matrix(list[0]);
            foreach (Matrices.Matrix i in list)
            {
                temp += i;
            }

            double maxik = Algorithms.MaxValue <double>(temp);

            double SYSIN            = 0.0;
            int    reachMatrixCount = 1;

            int N = temp.Rows;

            bool zeroDiagonal = false;

            for (int i = 0; i < N; i++)
            {
                if (temp[i, i] != 0)
                {
                    zeroDiagonal = false;
                    break;
                }
                zeroDiagonal = true;
            }

            if (!zeroDiagonal)
            {
                for (int i = 0; i < N; ++i)
                {
                    for (int j = 0; j < N; ++j)
                    {
                        SYSIN += temp[i, j];
                    }
                    SYSIN -= temp[i, i];
                }
                SYSIN *= (1 - maxik * N);
                SYSIN /= maxik;
                SYSIN /= (1 - Math.Pow(maxik * N, reachMatrixCount));
            }
            else
            {
                for (int i = 0; i < N; ++i)
                {
                    for (int j = 0; j < N; ++j)
                    {
                        SYSIN += temp[i, j];
                    }
                }
                SYSIN *= (1 - maxik * (N - 1));
                SYSIN /= maxik * (N - 1);
                SYSIN /= (1 - Math.Pow(maxik * (N - 1), reachMatrixCount));
            }

            return(SYSIN);
        }
Beispiel #3
0
 internal static global::Network.Matrices.Matrix GenerateWeightedCOCMatrix(List <clique> cliques, global::Network.Matrices.Matrix matrix)
 {
     Matrices.Matrix result = new Matrices.Matrix(matrix);
     for (int c = 0; c < matrix.Cols; c++)
     {
         for (int r = 0; r < matrix.Rows; r++)
         {
             result[r, c] *= cliques[c].num_networks;
         }
     }
     return(result);
 }
Beispiel #4
0
        private double calculate_InterdependenceWeightFile(List <Matrices.Matrix> list, List <int> year, List <int> networkid, List <double> weight)
        {
            Matrices.Matrix temp = new Matrices.Matrix(list[0]);

            for (int i = 0; i < list.Count; i++)
            {
                for (int row = 0; row < list[0].Rows; row++)
                {
                    for (int col = 0; col < list[0].Cols; col++)
                    {
                        list[i][row, col] *= weight[i];
                    }
                }
            }

            foreach (Matrices.Matrix i in list)
            {
                temp += i;
            }

            double maxik = Algorithms.MaxValue <double>(temp);

            double SYSIN            = 0.0;
            int    reachMatrixCount = 1;

            int N = temp.Rows;

            bool zeroDiagonal = false;

            for (int i = 0; i < N; i++)
            {
                if (temp[i, i] != 0)
                {
                    zeroDiagonal = false;
                    break;
                }
                zeroDiagonal = true;
            }

            if (!zeroDiagonal)
            {
                for (int i = 0; i < N; ++i)
                {
                    for (int j = 0; j < N; ++j)
                    {
                        SYSIN += temp[i, j];
                    }
                    SYSIN -= temp[i, i];
                }
                SYSIN *= (1 - maxik * N);
                SYSIN /= maxik;
                SYSIN /= (1 - Math.Pow(maxik * N, reachMatrixCount));
            }
            else
            {
                for (int i = 0; i < N; ++i)
                {
                    for (int j = 0; j < N; ++j)
                    {
                        SYSIN += temp[i, j];
                    }
                }
                SYSIN *= (1 - maxik * (N - 1));
                SYSIN /= maxik * (N - 1);
                SYSIN /= (1 - Math.Pow(maxik * (N - 1), reachMatrixCount));
            }

            return(SYSIN);
        }