Пример #1
0
        private void btGenerateFerguson_Click(object sender, EventArgs e)
        {
            FergusonModel Model = new FergusonModel(lbModelFerguson.Text);
            int           seq_length;

            if (int.TryParse(tbGeneratedSequenceLengthFerguson.Text, out seq_length))
            {
                if (Model.IsCorrect() == 1)
                {
                    DateTime startTime = DateTime.Now;
                    DateTime endTime;
                    Model.StartGenerator(seq_length, HSMPQApplication.Mode.Release, HSMPQApplication.PRNGMode.Random);
                    endTime = DateTime.Now;
                    TimeSpan employedTime = endTime - startTime;
                    // lbEmployedTime.Text = "Время, затраченное на генерацию " + employedTime.ToString();
                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        StreamReader f   = File.OpenText("res.txt");
                        string       Buf = f.ReadToEnd();
                        StreamWriter sw  = new StreamWriter(File.Create(saveFileDialog1.FileName));
                        sw.Write(Buf);
                        sw.Close();
                        f.Close();
                    }
                }
                else if (Model.IsCorrect() == 0)
                {
                    MessageBox.Show("Размерности вводимых параметров не соответствуют");
                }
            }
            else
            {
                MessageBox.Show("Введите длину последовательости ошибок");
            }
        }
Пример #2
0
        private void btCalculateFerguson_Click(object sender, EventArgs e)
        {
            FergusonModel Model = new FergusonModel(lbModelFerguson.Text);

            if (Model.IsCorrect() == 1)
            {
                int smbnubmer = 10;
                if (tbSequenceLengthFerguson.Text != "")
                {
                    try
                    {
                        smbnubmer = int.Parse(tbSequenceLengthFerguson.Text);
                    }
                    catch (Exception)
                    {
                    }
                }
                ;
                int[] res = new int[smbnubmer + 1];
                try
                {
                    res = HMM_PSM.GetOutputSequence(lbSequenceFerguson.Text, smbnubmer);
                }
                catch (Exception)
                {
                    MessageBox.Show("Желаемая длина последовательности превышает размер файла");
                    return;
                }
                panel3.Enabled = false;

                LikelihoodFerguson lk = new LikelihoodFerguson(res, Model);
                tbProbabilityFerguson.Text = lk.FullProbability(res.Length - 1).ToString();
                // tbProbabilityFerguson.Text = lk.Probability(res.Length - 1).ToString();
                string s = "";
                for (int i = 0; i < lk.alpha.GetLength(0); i++)
                {
                    for (int j = 0; j < lk.alpha.GetLength(1); j++)
                    {
                        for (int k = 0; k < lk.alpha.GetLength(2); k++)
                        {
                            s += "alpha(" + i + ", " + j + ", " + k + ")=" + lk.alpha[i, j, k].ToString() + "\r\n";
                        }
                    }
                }
                tbAlphaFerg.Text = s;
            }
            else
            {
                MessageBox.Show("Модель задана некорректно");
            }
        }
Пример #3
0
        public LikelihoodFerguson(int[] o, FergusonModel model)
        {
            O     = o;
            Model = model;
            int D = model.MaxPeriodOverall();

            alpha = new double[model.n, D + 1, o.Length + Model.MaxPeriodOverall()];
            P     = new double[o.Length + Model.MaxPeriodOverall()];
            for (int r = 0; r < o.Length + Model.MaxPeriodOverall(); r++)
            {
                for (int i = 0; i < model.n; i++)
                {
                    for (int d = 0; d <= D; d++)
                    {
                        alpha[i, d, r] = -1;
                    }
                }
                P[r] = -1;
            }
        }