Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //while (true)
            //{
            //    double d = r.Next(-1000,1000);
            //    MessageBox.Show(String.Format("F({0}) = {1}",d.ToString(),Constatnts.ActivationFunk(d).ToString("N3")));
            //}
            //neuro = new Neuro(2);
            //neuro.W[0] = 10;
            //neuro.W[1] = 10;
            //chart1.Series[0].Points.AddXY(-100, -100);
            //chart1.Series[0].Points.AddXY(100, 100);
            //chart1.ChartAreas[0].AxisX.Minimum = -100;
            //chart1.ChartAreas[0].AxisX.Maximum = 100;

            chart1.Series[0].Points.AddXY(10, 30);
            chart1.Series[0].Points.AddXY(40, 50);
            chart1.Series[0].Points.AddXY(50, 30);
            chart1.Series[0].Points.AddXY(40, 10);
            chart1.Series[0].Points.AddXY(20, 10);
            chart1.Series[0].Points.AddXY(10, 30);

            var levels = new int[] { 5, 2, 1 };

            neuro = new NeuroSystem(levels, 3);
        }
Пример #2
0
        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!");
        }