Exemple #1
0
 /// <summary>
 /// открыть коэфициенты
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button2_Click(object sender, EventArgs e)
 {
     richTextBox1.Text = "";
     richTextBox2.Text = "";
     if (listPeremens == null || listPeremens.Count == 0)
     {
         MessageBox.Show("Загрузите файл с переменными", "", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1);
         return;
     }
     GeneratorКомбинаций genkombi = new GeneratorКомбинаций(listPeremens);
     List<Kombinacia> allstkombo = genkombi.runGen();
     Fileload file = new Fileload();
     List<List<ValueFile>> learn = file.getDataFile();
     if (learn == null || learn.Count == 0)
         return;
     Proiz classProiz = new Proiz();
     double[][] proiz;
     double[] ylean;
     classProiz.getProiz(listPeremens, allstkombo, learn, out proiz, out ylean);
     if (provPrizAndYlean(proiz, ylean, learn.Count, allstkombo.Count + 1) == false)
         return;
     koef = new Fileload().getLoadKoef();
     if (koef == null || koef.Length == 0 && koef.Length == allstkombo.Count + 1)
         return;
     button1Prov.PerformClick();
 }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            infapred.Clear();
            ZemelYch.Clear();
            Proiz.Clear();
            OsnPred.Clear();

            getPredpriati(TPredpriatia.Text);

            int idpred = getPredpriatia(TPredpriatia.Text);

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Document (*.docx) | *.docx";

            try
            {
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    var newpathdoc = sfd.FileName;

                    //TODO
                    var wordAPP = new Word.Application();
                    wordAPP.Visible = false;

                    var worddocument = wordAPP.Documents.Open(TemplateFileName);

                    ReplateWordDocument("{Predpriatia}", infapred[0], worddocument);
                    ReplateWordDocument("{DataTime}", infapred[1], worddocument);
                    ReplateWordDocument("{VidSobs}", infapred[2], worddocument);
                    ReplateWordDocument("{Adres}", infapred[3], worddocument);
                    ReplateWordDocument("{Users}", infapred[4], worddocument);
                    ReplateWordDocument("{Phone}", infapred[5], worddocument);

                    //Таблица 1
                    var n = 0;
                    getOsnPred(idpred.ToString());
                    Word.Table tab = worddocument.Tables[1];
                    for (int i = 2; i <= (OsnPred.Count / 3) + 1; i++)
                    {
                        tab.Rows.Add(Missing.Value);
                        tab.Cell(i, 1).Range.Text = OsnPred[n];
                        n++;
                        tab.Cell(i, 2).Range.Text = OsnPred[n];
                        n++;
                        tab.Cell(i, 3).Range.Text = OsnPred[n];
                        n++;
                    }

                    //Таблица 2
                    n = 0;
                    getZemelYch(idpred.ToString());
                    tab = worddocument.Tables[2];
                    for (int i = 2; i <= (ZemelYch.Count / 3) + 1; i++)
                    {
                        tab.Rows.Add(Missing.Value);
                        tab.Cell(i, 1).Range.Text = ZemelYch[n];
                        n++;
                        tab.Cell(i, 2).Range.Text = ZemelYch[n];
                        n++;
                        tab.Cell(i, 3).Range.Text = ZemelYch[n];
                        n++;
                    }

                    //Таблица 3
                    n = 0;
                    getProiz(idpred.ToString());
                    tab = worddocument.Tables[3];
                    for (int i = 2; i <= (Proiz.Count / 2) + 1; i++)
                    {
                        tab.Rows.Add(Missing.Value);
                        tab.Cell(i, 1).Range.Text = Proiz[n];
                        n++;
                        tab.Cell(i, 2).Range.Text = Proiz[n];
                        n++;
                    }

                    worddocument.SaveAs(newpathdoc);
                    wordAPP.Visible = true;

                    MessageBox.Show("Документ сохранен", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            {
                MessageBox.Show("Произошла ошибка.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #3
0
 public Server(int ГВ, int Ц, int СЭ, Proiz П) : base(ГВ, Ц, СЭ)
 {
     Производитель = П;
 }
Exemple #4
0
 private void button2Gradient_Click(object sender, EventArgs e)
 {
     richTextBox1.Text = "";
     richTextBox2.Text = "";
     if (listPeremens == null || listPeremens.Count == 0)
     {
         MessageBox.Show("Загрузите файл с переменными", "", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1);
         return;
     }
     GeneratorКомбинаций genkombi = new GeneratorКомбинаций(listPeremens);
     List<Kombinacia> allstkombo = genkombi.runGen();
     Fileload file = new Fileload();
     List<List<ValueFile>> learn = file.getDataFile();
     if (learn == null || learn.Count == 0)
         return;
     DialogQ q = new DialogQ();
     if (learn.Count > 10000)
     {
         DialogResult r = MessageBox.Show("Файл обучения содержит " + learn.Count +
             " строк. Умешить для ускорения работы алгоритма градиентного спуска",
             "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
         if (r == DialogResult.Yes)
         {
         retq:
             q.Text = "Количество элементов файла обучения";
             q.setText("Введите количество элементов, которые необходимо забрать из файла");
             q.ShowDialog();
             int len = q.getValueInt();
             if (len > learn.Count || len == -1)
                 goto retq;
             else if (len != -2)
                 learn = learn.GetRange(0, len);
         }
     }
     Proiz classProiz = new Proiz();
     double[][] proiz;
     double[] ylean;
     classProiz.getProiz(listPeremens, allstkombo, learn, out proiz, out ylean);
     if (provPrizAndYlean(proiz, ylean, learn.Count, allstkombo.Count + 1) == false)
         return;
     double eps = 1.0, la = 0.0001;
     eps = Properties.Settings.Default.eps;
     la = Properties.Settings.Default.lamda;
     textBox1.Text = "start time: " + DateTime.Now;
     toolStripLabel1.Text = "Работает градиентный спуск";
     toolStripProgressBar1.Value = 1;
     learn.Clear();
     new Thread(delegate()
     {
         GradientСпуск grad = new GradientСпуск(proiz, ylean, eps, la, allstkombo.Count + 1, this);
         koef = grad.runСпуск();
         Invoke(new MethodInvoker(() =>
         {
             toolStripLabel1.Text = "Градиентный спуск закончил работу";
             foreach (var i in koef)
                 richTextBox2.Text += i + "\t";
             richTextBox1.Text = "end time: " + DateTime.Now + "\n" + richTextBox1.Text;
         }));
         resUr = allstkombo;
     }).Start();
 }