コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            Shedule.L         = _l;
            Shedule.Switching = _temptS;
            Shedule.Treatment = _temptT;
            _countType        = (int)numericUpDown1.Value;
            _countBatches     = Convert.ToInt32(countBatchesTB.Text);
            var listCountButches = new List <int>();

            for (var ii = 0; ii < _countType; ii++)
            {
                listCountButches.Add(_countBatches);
            }
            var gaa = new GAA(_countType, listCountButches, checkBox1.Checked);

            gaa.SetXrom((int)numericUpDown2.Value);
            gaa.calcFitnessList();
            int s;
            var result = gaa.getSelectionPopulation(_selectionType, out s);

            using (var file = new StreamWriter("outputGAA.txt", true))
            {
                int i = 0;
                foreach (var elem in gaa.nabor)
                {
                    foreach (var elem2 in elem.GenList)
                    {
                        foreach (var elem3 in elem2)
                        {
                            file.Write(elem3 + " ");
                        }
                        file.WriteLine();
                    }
                    file.WriteLine("_________________________");
                    file.WriteLine(gaa._fitnesslist[i]);
                    file.WriteLine("_________________________");
                    i++;
                }
                file.WriteLine("***************************");
                file.WriteLine(result);
                file.WriteLine("***************************");
            }
            MessageBox.Show("Данные успешно записаны", "Учпешное завершение", MessageBoxButtons.OK);
        }
コード例 #2
0
        private void button5_Click(object sender, EventArgs e)
        {
            var massi = new[] { 8, 12, 16, 24, 32 };

            foreach (var intt in massi)
            {
                countBatchesTB.Text = intt.ToString();
                for (int z = 5; z <= 10; z += 5)
                {
                    numericUpDown1.Text = z.ToString();
                    for (int z1 = 5; z1 <= 10; z1 += 5)
                    {
                        LTB.Text = z1.ToString();
                        using (var file = new StreamWriter("outputGAASimpleResult.txt", true))
                        {
                            file.WriteLine("________________(CB = " + intt + ")");
                            file.WriteLine();
                            file.WriteLine("________________(L = " + LTB.Text + ")(N=" + numericUpDown1.Value + ")_____");
                        }
                        for (int p = 2; p <= 32; p *= 2)
                        {
                            timeTreatmentingTB.Text = Convert.ToString(p);
                            for (int i = 2; i <= 32; i *= 2)
                            {
                                timeSwitchingTB.Text = Convert.ToString(i);

                                Shedule.L         = _l;
                                Shedule.Switching = _temptS;
                                Shedule.Treatment = _temptT;
                                _countType        = (int)numericUpDown1.Value;
                                _countBatches     = Convert.ToInt32(countBatchesTB.Text);
                                var listCountButches = new List <int>();
                                for (var ii = 0; ii < _countType; ii++)
                                {
                                    listCountButches.Add(_countBatches);
                                }
                                var gaa = new GAA(_countType, listCountButches, checkBox1.Checked);
                                gaa.SetXrom((int)numericUpDown2.Value);
                                var countSourceKit = gaa.calcFitnessList();
                                int s;
                                var result = gaa.getSelectionPopulation(_selectionType, out s);

                                using (var file = new StreamWriter("outputGAA.txt", true))
                                {
                                    int k = 0;
                                    foreach (var elem in gaa.nabor)
                                    {
                                        foreach (var elem2 in elem.GenList)
                                        {
                                            foreach (var elem3 in elem2)
                                            {
                                                file.Write(elem3 + " ");
                                            }
                                            file.WriteLine();
                                        }
                                        file.WriteLine("_________________________");
                                        file.WriteLine(gaa._fitnesslist[i]);
                                        file.WriteLine("+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=");
                                        file.WriteLine("Kit" + countSourceKit[i]);
                                        file.WriteLine("+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=");
                                        file.WriteLine("_________________________");
                                        k++;
                                    }

                                    file.WriteLine("***************************");
                                    file.WriteLine(result);
                                    file.WriteLine("***************************");
                                }
                                using (var file = new StreamWriter("outputGAASimpleResult.txt", true))
                                {
                                    file.WriteLine(result);
                                }
                            }
                            using (var file = new StreamWriter("outputGAASimpleResult.txt", true))
                            {
                                file.WriteLine("_____________________");
                            }
                        }
                    }
                }
            }
            MessageBox.Show("Данные успешно записаны", "Учпешное завершение", MessageBoxButtons.OK);
        }
コード例 #3
0
        private void OldSecondLevelAll_Click(object sender, EventArgs e)
        {
            var massi = new[] { 2, 4, 8, 16, 32 };

            using (var file = new StreamWriter("Га, оптимизации групп " + OptimizationSecondLevel.Checked + " N=" + numericUpDown1.Value + "L=" + LTB.Text + ".txt", false))
            {
                foreach (var intt in massi)
                {
                    timeSwitchingTB.Text = intt.ToString();
                    foreach (var item in massi)
                    {
                        for (var tz = 50; tz <= 200; tz = tz + 50)
                        {
                            for (var countGroup = 2; countGroup <= 8; countGroup += 2)
                            {
                                timeTreatmentingTB.Text = item.ToString();
                                _countType    = (int)numericUpDown1.Value;
                                _countBatches = Convert.ToInt32(countBatchesTB.Text);
                                var listCountButches = new List <int>();
                                for (var ii = 0; ii < _countType; ii++)
                                {
                                    listCountButches.Add(_countBatches);
                                }

                                _l    = Convert.ToInt32(LTB.Text);
                                _maxS = Convert.ToInt32(timeSwitchingTB.Text);
                                _maxT = Convert.ToInt32(timeTreatmentingTB.Text);
                                GetTime();
                                Shedule.L         = _l;
                                Shedule.Switching = _temptS;
                                Shedule.Treatment = _temptT;

                                var gaa = new GAA(_countType, listCountButches, checkBox1.Checked, _countBatches);
                                gaa.SetXrom((int)numericUpDown2.Value);
                                var sostav = gaa.calcFitnessList();

                                //var firstLevel = new FirstLevel(_countType, listCountButches, checkBox1.Checked);
                                //firstLevel.GenetateSolutionForAllTypes("outputFirstAlgorithm.txt");
                                var oldSecondLevel = new OldSecondLevel(tz, countGroup, _l);

                                int criteria;
                                int flCrit;
                                var listInt = !OptimizationSecondLevel.Checked
                                    ? oldSecondLevel.CalcFitnessList(sostav, out criteria, out flCrit)
                                    : oldSecondLevel.CalcOptimalFitnessList(sostav, out criteria, out flCrit);
                                var stringTime = listInt.Select(i => i.ToString());
                                var join       = string.Join(" ", stringTime);
                                file.WriteLine("Tz = " + tz.ToString() + Environment.NewLine +
                                               "Tp = " + intt + Environment.NewLine +
                                               "Z = " + countGroup + Environment.NewLine +
                                               "Crit = " + criteria + Environment.NewLine +
                                               "fLCrit = " + flCrit + Environment.NewLine +
                                               "To = " + item + Environment.NewLine +
                                               listInt.Sum().ToString() + join + Environment.NewLine + Environment.NewLine);
                            }
                        }
                    }
                }
            }
            MessageBox.Show(@"Решения найдены");
        }