private void button1_Click(object sender, EventArgs e) { int countOfWindow = int.Parse(textBox5.Text); var levels = new int[] { int.Parse(textBox4.Text), 1 }; neuro = new NeuroSystem(levels, countOfWindow); var data = Constatnts.GetArray(double.Parse(textBox1.Text), double.Parse(textBox2.Text), double.Parse(textBox3.Text)); double max = double.MinValue; double min = double.MaxValue; for (int i = 0; i < data.Length; i++) { max = Math.Max(max, data[i].Y); min = Math.Min(min, data[i].Y); } Constatnts._XMax = max; Constatnts._XMin = min; double E = double.MaxValue; for (int index = countOfWindow; index < data.Length - 2; index++) { for (int i = countOfWindow; i <= index; i++) { double[] arr = new double[countOfWindow]; int k = 0; for (int j = i - countOfWindow; j < i; j++) { arr[k] = Constatnts.TransformerAlong(data[j].Y); k++; } neuro.SetX(arr); double d = (Constatnts.TransformerAlong(data[i + 1].Y)); double s = neuro.GetResult(); E = Math.Pow(d - s, 2); while (E > Constatnts._Epselon) { neuro.Teach(d, s); s = neuro.GetResult(); E = Math.Pow(d - s, 2); } } } MessageBox.Show("Done!"); }
private void button1_Click(object sender, EventArgs e) { List <double[]> list = new List <double[]>(); for (int i = 0; i < 100; i++) { double x = 6 * Math.Truncate(i / 10d); double some = i % 10d; double y = 6 * some; double[] xArr = new double[] { x / 60d, y / 60d, 1d }; list.Add(xArr); } double E = double.MaxValue; int counter = 1; while (E > Constatnts._Epselon) { E = double.MinValue; for (int j = 0; j < counter; j++) { bool b = pointInterceptPolygon(new Point(list[j][0], list[j][1]), ls); double d; if (b) { d = 1; } else { d = 0; } neuro.SetX(list[j]); double s = neuro.GetResult(); if (Math.Pow(d - s, 2) / 2d > Constatnts._Epselon) { neuro.Teach(d, s); s = neuro.GetResult(); } if (Math.Pow(d - s, 2) / 2d > E) { E = Math.Pow(d - s, 2) / 2.0; } } if (counter != list.Count && E < Constatnts._Epselon) { counter++; E = double.MaxValue; } } /* * for (int i = 0; i < list.Count; i++) * { * double[] xArr = list[i]; * neuro.SetX(xArr); * double s = neuro.GetResult(); * bool b = pointInterceptPolygon(new Point(xArr[0], xArr[1]), ls); * double d; * if (b) d = 1; * else d = 0; * double E = Math.Pow(d - s, 2) / 2; * neuro.SetX(xArr); * while (E > Constatnts._Epselon) * { * neuro.Teach(d, s); * s = neuro.GetResult(); * E = Math.Pow(d - s, 2) / 2; * } * }*/ MessageBox.Show("Done!"); }