Ejemplo n.º 1
0
        public KolmogorovMatrix(StatesMatrix statesMatrix)
            : this(statesMatrix.Dimension)
        {
            //double sum;
            for (int i = 0; i < statesMatrix.Dimension; i++)
            {
                //sum = 0;
                for (int j = 0; j < statesMatrix.Dimension; j++)
                {
                    if (statesMatrix[i, j] == 0 && statesMatrix[j, i] == 0)
                    {
                        this.matrix[i, j] = 0;
                    }
                    else if (statesMatrix[i, j] != 0 && statesMatrix[j, i] == 0)
                    {
                        this.matrix[i, j] = -statesMatrix[i, j];
                        //sum = sum - statesMatrix[i, j];
                    }
                    else if (statesMatrix[i, j] == 0 && statesMatrix[j, i] != 0)
                    {
                        this.matrix[i, j] = statesMatrix[j, i];
                        //sum = sum + statesMatrix[j, i];
                    }
                    else if (statesMatrix[i, j] != 0 && statesMatrix[j, i] != 0)
                    {
                        this.matrix[i, j] = statesMatrix[j, i] - statesMatrix[i, j];
                        //sum = sum + statesMatrix[j, i] - statesMatrix[i, j];
                    }
                }
                //StatesMatrix.Intensity.Add( sum );
            }
            for (int j = 0; j < this.Dimension; j++)
            {
                matrix[this.Dimension - 1, j] = 1;
            }

            B = new double[Dimension];
            for (int i = 0; i < this.Dimension; i++)
            {
                if (i != Dimension - 1)
                {
                    B[i] = 0;
                }
                else
                {
                    B[i] = 1;
                }
            }
        }
Ejemplo n.º 2
0
        private void CalculateButton_Click(object sender, EventArgs e)
        {
            //Transfer data in array
            StatesMatrix matrix = new StatesMatrix(Table.RowsAndCols);
            int          parseResult;

            for (int i = 0; i < Table.RowsAndCols; i++)
            {
                for (int j = 0; j < Table.RowsAndCols; j++)
                {
                    if (dataGridView1.Rows[i].Cells[j].Value != null)
                    {
                        if (int.TryParse(dataGridView1.Rows[i].Cells[j].Value.ToString(), out parseResult) == true)
                        {
                            matrix[i, j] = parseResult;
                        }
                        else
                        {
                            MessageBox.Show("Wrong input! Please put in table only numbers.");
                        }
                    }
                    else
                    {
                        matrix[i, j] = 0;
                    }
                }
            }

            KolmogorovMatrix kolmogorov = new KolmogorovMatrix(matrix);

            double[] array = kolmogorov.Solve();
            int      n     = 0;

            foreach (var x in array)
            {
                listView1.Items.Add($"P{n}(t) = " + x.ToString());
                listView1.Items.Add($"time{n}:" + (((x * (1 - x)) / 0.0025) * 2.7).ToString());
            }
        }