public static weights generate() { weights W = new weights(); Random rnd = new Random(); W.height = (new int[] { rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999) }); W.clear = new int[] { 0, rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999) }; // 1 2 3 4 // combo时也许不一样 W.tspin = new int[] { rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999) }; // mini 1 2 3 W.tslot = new int[] { rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999) }; W.wide = rnd.Next(-9999, 9999); W.b2b = rnd.Next(-9999, 9999); W.b2b_clear = rnd.Next(-9999, 9999); W.wastedT = rnd.Next(-9999, 9999); W.movetime = -3; // 操作数 //W. tslotnum; // t坑数目jla W.holdT = rnd.Next(-9999, 9999); W.holdI = rnd.Next(-9999, 9999); W.perfectclear = rnd.Next(-9999, 9999); W.bus = rnd.Next(-9999, 9999); W.bus_sq = rnd.Next(-9999, 9999); W.fewcombo = rnd.Next(-9999, 9999); W.combo = rnd.Next(-9999, 9999); // maybe combo table W.maxdef = rnd.Next(-9999, 9999); // 最高防御垃圾行 W.attack = rnd.Next(-9999, 9999); // 攻击 W.downstack = rnd.Next(-9999, 9999); W.deephole = rnd.Next(-9999, 9999); W.atk = rnd.Next(-9999, 9999); W.def = rnd.Next(-9999, 9999); W.atk = rnd.Next(-9999, 9999); W.def = rnd.Next(-9999, 9999); W.maxatk = rnd.Next(-9999, 9999); W.maxdef = rnd.Next(-9999, 9999); W.parity = rnd.Next(-9999, 9999); W.dephigh = rnd.Next(-9999, 9999); W.linefull = rnd.Next(-9999, 9999); // -5 W.col_minhigh = new int[] { rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999), rnd.Next(-9999, 9999) }; return(W); }
CheckUserValues(label, features, weights, numberOfLeaves, minimumExampleCountPerLeaf, learningRate, numberOfIterations, onFit);
CheckUserValues(label, features, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound, onFit);
public battle(weights w1, weights w2) { this.w1 = w1; this.w2 = w2; }
public battle() { w1 = new weights(); w2 = new weights(); }
public static weights crossover(weights p1, weights p2) { Random rnd = new Random(); weights chird = new weights(); chird.height = (new int[] { crossover_gene(p1.height[0], p2.height[0]), crossover_gene(p1.height[1], p2.height[1]), crossover_gene(p1.height[2], p2.height[2]), crossover_gene(p1.height[3], p2.height[3]), crossover_gene(p1.height[4], p2.height[4]) }); chird.clear = new int[] { 0, crossover_gene(p1.clear[1], p2.clear[1]), crossover_gene(p1.clear[2], p2.clear[2]), crossover_gene(p1.clear[3], p2.clear[3]), crossover_gene(p1.clear[4], p2.clear[4]) }; // 1 2 3 4 // combo时也许不一样 chird.tspin = new int[] { crossover_gene(p1.tspin[0], p2.tspin[0]), crossover_gene(p1.tspin[1], p2.tspin[1]), crossover_gene(p1.tspin[2], p2.tspin[2]), crossover_gene(p1.tspin[3], p2.tspin[3]) }; // mini 1 2 3 chird.tslot = new int[] { crossover_gene(p1.tslot[0], p2.tslot[0]), crossover_gene(p1.tslot[1], p2.tslot[1]), crossover_gene(p1.tslot[2], p2.tslot[2]), crossover_gene(p1.tslot[3], p2.tslot[3]), crossover_gene(p1.tslot[4], p2.tslot[4]) }; // mini 1 2 3 chird.wide = crossover_gene(p1.wide, p2.wide); chird.b2b = crossover_gene(p1.b2b, p2.b2b); chird.b2b_clear = crossover_gene(p1.b2b_clear, p2.b2b_clear); chird.wastedT = crossover_gene(p1.wastedT, p2.wastedT); chird.movetime = -3; // 操作数 //chird. tslotnum; // t坑数目jla chird.holdT = crossover_gene(p1.holdT, p2.holdT); chird.holdI = crossover_gene(p1.holdI, p2.holdI); chird.perfectclear = crossover_gene(p1.perfectclear, p2.perfectclear); chird.bus = crossover_gene(p1.bus, p2.bus); chird.bus_sq = crossover_gene(p1.bus_sq, p2.bus_sq); chird.fewcombo = crossover_gene(p1.fewcombo, p2.fewcombo); chird.combo = crossover_gene(p1.combo, p2.combo); // maybe combo table chird.maxdef = crossover_gene(p1.maxdef, p2.maxdef); // 最高防御垃圾行 chird.attack = crossover_gene(p1.attack, p2.attack); // 攻击 chird.downstack = crossover_gene(p1.downstack, p2.downstack); chird.deephole = crossover_gene(p1.deephole, p2.deephole); chird.atk = crossover_gene(p1.atk, p2.atk); chird.def = crossover_gene(p1.def, p2.def); chird.maxatk = crossover_gene(p1.def, p2.def); chird.maxdef = crossover_gene(p1.def, p2.def); chird.deltcol = crossover_gene(p1.deltcol, p2.deltcol); chird.safecost = crossover_gene(p1.safecost, p2.safecost); chird.parity = crossover_gene(p1.parity, p2.parity); chird.dephigh = crossover_gene(p1.dephigh, p2.dephigh); chird.linefull = crossover_gene(p1.linefull, p2.linefull); // -5 chird.col_minhigh = new int[] { crossover_gene(p1.col_minhigh[0], p2.col_minhigh[0]), crossover_gene(p1.col_minhigh[1], p2.col_minhigh[1]), crossover_gene(p1.col_minhigh[2], p2.col_minhigh[2]), crossover_gene(p1.col_minhigh[3], p2.col_minhigh[3]), crossover_gene(p1.col_minhigh[4], p2.col_minhigh[4]), crossover_gene(p1.col_minhigh[5], p2.col_minhigh[5]), crossover_gene(p1.col_minhigh[6], p2.col_minhigh[6]), crossover_gene(p1.col_minhigh[7], p2.col_minhigh[7]), crossover_gene(p1.col_minhigh[8], p2.col_minhigh[8]), crossover_gene(p1.col_minhigh[9], p2.col_minhigh[9]), }; return(chird); }
private void saveWeigths() { bool truePos = true; for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1[1, i].Value == null) { truePos = false; } } if (truePos) { for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1[0, i].Value != null) { namesMarks.Add(dataGridView1[0, i].Value.ToString()); } if (dataGridView1[1, i].Value != null) { weightMarks.Add(dataGridView1[1, i].Value.ToString()); } } StreamWriter saveSettings = new StreamWriter(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Электронный журнал\\marksName.json")); try { weights myCollection = new weights(); myCollection.weightsMarks = new weightsMarks[weightsMarksData.weightsMarks.Length + notFoundNames.Count]; int count = 0; for (int i = 0; i < weightsMarksData.weightsMarks.Length; i++) { for (int j = 0; j < weightMarks.Count; j++) { if (weightsMarksData.weightsMarks[i].name == namesMarks[j] && weightsMarksData.weightsMarks[i].weight != Convert.ToInt16(this.weightMarks[j])) { weightsMarksData.weightsMarks[i].weight = Convert.ToInt16(this.weightMarks[j]); } } for (int k = 0; k < weightBuff.Count; k++) { for (int j = 0; j < weightsMarksData.weightsMarks.Length; j++) { if (weightBuff[k] == weightsMarksData.weightsMarks[j].name) { this.weightBuff[k] = weightsMarksData.weightsMarks[j].weight.ToString(); break; } } } myCollection.weightsMarks[i] = new weightsMarks() { name = weightsMarksData.weightsMarks[i].name, weight = weightsMarksData.weightsMarks[i].weight }; count++; } int countAddMarks = 0; for (int i = 0; i < notFoundNames.Count; i++) { for (int j = 0; j < namesMarks.Count; j++) { if (notFoundNames[i] == namesMarks[j]) { notFoundWeights.Add(weightMarks[j]); } } myCollection.weightsMarks[count] = new weightsMarks() { name = notFoundNames[countAddMarks], weight = Convert.ToInt16(notFoundWeights[countAddMarks]) }; countAddMarks++; count++; } for (int i = 0; i < weightBuff.Count; i++) { for (int j = 0; j < myCollection.weightsMarks.Length; j++) { if (weightBuff[i] == myCollection.weightsMarks[j].name) { weightBuff[i] = myCollection.weightsMarks[j].weight.ToString(); } } } saveSettings.Write(JsonConvert.SerializeObject(myCollection)); //Formatting.Indented } catch { } finally { saveSettings.Close(); } saveMarks = true; this.Close(); } else { MessageBox.Show("Проверьте правильность заполнения весов работ!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public addValuesDnevnik(List <string> weights) { InitializeComponent(); for (int i = 0; i < weights.Count; i++) { weightBuff.Add(weights[i]); } if (Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Электронный журнал"))) { if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Электронный журнал\\marksName.json"))) { string marksName = ""; StreamReader openSettings = new StreamReader(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Электронный журнал\\marksName.json")); try { marksName = openSettings.ReadLine(); } catch { } finally { openSettings.Close(); } //string weightsText = JsonConvert.SerializeObject(marksName); weightsMarksData = JsonConvert.DeserializeObject <weights>(marksName); //MessageBox.Show($"{settingsValues[0]}\n{settingsValues[1]}\n{settingsValues[2]}\n{settingsValues[3]}\n{settingsValues[4]}\n{settingsValues[5]}\n{settingsValues[6]}\n{settingsValues[7]}\n{settingsValues[8]}\n{settingsValues[9]}\n{settingsValues[10]}\n{settingsValues[11]}\n{settingsValues[12]}\n{settingsValues[13]}\n{settingsValues[14]}\n{settingsValues[15]}"); } else { string[] namesMarks = new string[25] { "Ответ на уроке", "Работа на уроке", "Диктант", "Работа с контурными картами", "Самостоятельная работа", "Контрольное списывание", "Словарный диктант", "Проверочная работа", "Аудирование", "Сочинение", "Изложение", "Практическая работа", "Лабораторная работа", "Творческая работа", "Контрольная", "Административная контрольная работа", "Итоговая контрольная работа", "Контрольный диктант", "Итоговый контрольный диктант", "Тест", "Зачет", "Государственная итоговая аттестация", "Входная контрольная работа", "Входной контрольный диктант", "Работа над ошибками" }; int[] weigthMarks = new int[25] { 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }; StreamWriter saveSettings = new StreamWriter(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Электронный журнал\\marksName.json")); try { weights myCollection = new weights(); myCollection.weightsMarks = new weightsMarks[25]; for (int i = 0; i < 25; i++) { myCollection.weightsMarks[i] = new weightsMarks() { name = namesMarks[i], weight = weigthMarks[i] }; } weightsMarksData = myCollection; saveSettings.Write(JsonConvert.SerializeObject(myCollection)); //Formatting.Indented } catch { } finally { saveSettings.Close(); } } } else { Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Электронный журнал")); } //вставка весов и названий работ if (weights.Count > 0) { List <string> names = new List <string> { weights[0] }; for (int i = 0; i < weights.Count; i++) { for (int j = 0; j < names.Count; j++) { if (weights[i] == names[j]) { for (int k = 0; k < weights.Count; k++) { if (weights[k] == names[j]) { weights.RemoveAt(k); k = -1; } } i = -1; } else { bool match = false; for (int k = 0; k < weights.Count; k++) { for (int f = 0; f < names.Count; f++) { if (weights[k] == names[f]) { match = true; } } } if (!match) { names.Add(weights[i]); } } } } dataGridView1.Rows.Clear(); for (int i = 0; i < names.Count; i++) { dataGridView1.Rows.Add(); } for (int i = 0; i < names.Count; i++) { dataGridView1[0, i].Value = names[i]; for (int k = 0; k < weightsMarksData.weightsMarks.Length; k++) { if (weightsMarksData.weightsMarks[k].name == names[i]) { dataGridView1[1, i].Value = (dataGridView1.Columns[1] as DataGridViewComboBoxColumn).Items[weightsMarksData.weightsMarks[k].weight - 1]; break; } } } dataGridView1.Sort(dataGridView1.Columns[1], ListSortDirection.Ascending); for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1[1, i].Value == null) { notFoundNames.Add(dataGridView1[0, i].Value.ToString()); } } Width = dataGridView1[0, 0].Size.Width + dataGridView1[1, 0].Size.Width + 40; } }
public Item(weights Weights) { this.Weights = Weights; }