private void OldSecondLevelButton_Click(object sender, EventArgs e) { var massi = new[] { 2, 4, 8, 16, 32 }; using (var file = new StreamWriter("Фиксированные партии - " + checkBox1.Checked + ", оптимизации групп " + 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 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(firstLevel._a, out criteria, out flCrit) : oldSecondLevel.CalcOptimalFitnessList(firstLevel._a, 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(@"Решения найдены"); }
private void button3_Click(object sender, EventArgs e) { _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); GetTime(); Shedule.L = _l; Shedule.Switching = _temptS; Shedule.Treatment = _temptT; var firstLevel = new FirstLevel(_countType, listCountButches, checkBox1.Checked); firstLevel.GenetateSolutionForAllTypesSecondAlgorithm(); }
private void button4_Click(object sender, EventArgs e) { int[] N_komplect_type = { 2 }; int[] N_komplect_for_type = { 2, 4 }; int[] N_komplect_sostav = { 2, 4 }; int[] n = { 5, 10 }; int[] l = { 5, 10 }; int[] time = { 2, 4, 8, 16, 32 }; string file = "test/testFile_"; using (var fileOut = new StreamWriter(file + "All.txt")) { foreach (var n_kom in N_komplect_type) { compositionSets = new List <List <int> >(); timeSets = new List <List <int> >(); foreach (var n_kom_q in N_komplect_for_type) { for (int i = 0; i < n_kom; i++) { compositionSets.Add(new List <int>()); timeSets.Add(new List <int>()); for (int j = 0; j < n_kom_q; j++) { timeSets[i].Add(140); } } foreach (var n_kom_s in N_komplect_sostav) { foreach (var t in n) { _countType = t; for (int i = 0; i < n_kom; i++) { for (var ind = 0; ind < _countType; ind++) { compositionSets[i].Add(n_kom_s); } } foreach (var _countLine in l) { foreach (var t2 in time) { foreach (var t3 in time) { _temptS = new List <List <List <int> > >(); _temptT = new List <List <int> >(); _l = _countLine; _maxS = t3; _maxT = t2; RandomTime(); PrintTime(); GetTime(); Shedule.L = _countLine; Shedule.Switching = _temptS; Shedule.Treatment = _temptT; var listCountButches = new List <int>(); for (var ii = 0; ii < _countType; ii++) { listCountButches.Add(0); } for (var ii = 0; ii < _countType; ii++) { _countBatches = 0; for (int i = 0; i < n_kom; i++) { _countBatches += compositionSets[i][ii] * n_kom_q; } listCountButches[ii] = _countBatches; } var firstLevel = new FirstLevel(_countType, listCountButches, checkBox1.Checked); var result = firstLevel.GenetateSolutionForAllTypesSecondAlgorithm(); var first = Convert.ToInt32(result[0]); var top = Convert.ToInt32(result[1]); fileOut.WriteLine(first + "\t" + top); } } fileOut.WriteLine(); } } fileOut.WriteLine("{-------------------------------------------------------------}"); } fileOut.WriteLine("/-------------------------------------------------------------/"); } } fileOut.Close(); } MessageBox.Show("Тестовый прогон завершен"); }
private void button4_Click(object sender, EventArgs e) { Form1.direct = checkBox2.Checked; int[] N_komplect_sostav = { 2, 4 }; int[] n = { 5, 10 }; int[] l = { 5, 10 }; int[] time = { 2, 4, 8, 16, 32 }; var file = "test/testFile_"; var str = "direct"; if (!Form1.direct) { str = "first_task"; } var n_kom = Convert.ToInt32(textBox1.Text); var rand = new Random((int)DateTime.Now.ToBinary()); var temp = 0; var n_kom_q = Convert.ToInt32(textBox2.Text); var fileOut = new StreamWriter(file + "All_" + str + "_" + n_kom + "_" + n_kom_q + "_new.txt", true); timeSets = new List <List <int> >(); //foreach(var n_kom_q in N_komplect_for_type) { for (int i = 0; i < n_kom; i++) { temp = rand.Next(10); if (temp > 5) { temp = 150; } else { temp = 100; } timeSets.Add(new List <int>()); for (int j = 0; j < n_kom_q; j++) { timeSets[i].Add((j + 1) * temp); } } foreach (var n_kom_s in N_komplect_sostav) { foreach (var t in n) { _countType = t; compositionSets = new List <List <int> >(); for (int i = 0; i < n_kom; i++) { compositionSets.Add(new List <int>()); for (var ind = 0; ind < _countType; ind++) { temp = rand.Next(10); if (temp > 5) { compositionSets[i].Add(n_kom_s); } else { compositionSets[i].Add(2); } } } foreach (var _countLine in l) { fileOut.WriteLine("Kq=" + n_kom_q); fileOut.WriteLine("Kqs=" + n_kom_s); fileOut.WriteLine("N=" + t + "L=" + _countLine); fileOut.WriteLine("Times"); fileOut.WriteLine(printArray(timeSets)); fileOut.WriteLine("Compositions"); fileOut.WriteLine(printArray(compositionSets)); foreach (var t2 in time) { foreach (var t3 in time) { _temptS = new List <List <List <int> > >(); _temptT = new List <List <int> >(); _l = _countLine; _maxS = t3; _maxT = t2; RandomTime(); PrintTime(); GetTime(); Shedule.L = _countLine; Shedule.Switching = _temptS; Shedule.Treatment = _temptT; var listCountButches = new List <int>(); for (var ii = 0; ii < _countType; ii++) { listCountButches.Add(0); } for (var ii = 0; ii < _countType; ii++) { _countBatches = 0; for (int i = 0; i < n_kom; i++) { _countBatches += compositionSets[i][ii]; } listCountButches[ii] = _countBatches * n_kom_q; } var firstLevel = new FirstLevel(_countType, listCountButches, checkBox1.Checked); var result = firstLevel.GenetateSolutionForAllTypesSecondAlgorithm(); var gaa = new GAA(_countType, listCountButches, checkBox1.Checked, _countBatches); var resultGaa = gaa.calcSetsFitnessList(checkBox2.Checked, GenerationCounter.Value, (int)numericUpDown2.Value); var first = result[0]; var top = result[1]; fileOut.WriteLine(first + "\t" + top + "\t" + resultGaa); } } } } } } fileOut.Close(); MessageBox.Show("Тестовый прогон завершен"); }