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 button3_Click(object sender, EventArgs e) { Clear(); var res = Constatnts.GetArray(double.Parse(textBox1.Text), double.Parse(textBox2.Text), double.Parse(textBox3.Text)); foreach (var elem in res) { chart1.Series[0].Points.AddXY(elem.X, elem.Y); chart1.Series[2].Points.AddXY(elem.X, elem.Y); } int cp = int.Parse(textBox5.Text); double step = double.Parse(textBox3.Text); double lastPoint = double.Parse(textBox2.Text) - (cp * step); var data = Constatnts.GetArray(double.Parse(textBox1.Text), double.Parse(textBox2.Text), double.Parse(textBox3.Text)); var ls = new List <double>(); for (int i = data.Length - 2 * cp; i < data.Length - cp; i++) { ls.Add(Constatnts.TransformerAlong(data[i].Y)); } // lastPoint += step; int index = data.Length - cp; for (int i = 0; i < cp; i++) { neuro.SetX(ls.ToArray()); double s = neuro.GetResult(); double real = Constatnts.TransformerBack(s); chart1.Series[1].Points.AddXY(lastPoint, real); chart1.Series[3].Points.AddXY(lastPoint, real); ls.Add(s); ls.RemoveAt(0); lastPoint += step; dataGridView1.Rows.Add(i + 1, data[index + i].Y.ToString("N4"), real.ToString("N4"), (Constatnts.GetPercError(real, data[index + i].Y) * 100).ToString("N2")); } this.Refresh(); }