Esempio n. 1
0
        public void DrawSOM(Point randomPoint)
        {
            List <Point> neurony = som.ReturnNeuronList();

            // Updating information in labels
            iteracja_label.Text = som.IterationNumber.ToString();
            wspolczynnik_uczenia_akt_label.Text = som.LearningRate.ToString();
            promien_sasiedztwa_textBox.Text     = som.NeighborhoodRadius.ToString();

            // Draw triangle, random point and all neurons
            Graphics g = som_pictureBox.CreateGraphics();

            g.Clear(Color.White);

            shape.Draw(som_pictureBox);

            DrawPoint(randomPoint.X, randomPoint.Y, Brushes.Red);

            for (int i = 0; i < neurony.Count - 1; i++)
            {
                if (i == 0)
                {
                    DrawPoint(neurony[i].X, neurony[i].Y, Brushes.Black);
                }
                DrawEdge(neurony[i], neurony[i + 1]);
                DrawPoint(neurony[i + 1].X, neurony[i + 1].Y, Brushes.Black);
            }
        }
Esempio n. 2
0
        private void start_button_Click(object sender, EventArgs e)
        {
            // Protection of the entered data
            if (liczba_neuronow_textBox.Text.Length == 0)
            {
                MessageBox.Show("Podaj liczbe neuronow!", "Blad", MessageBoxButtons.OK);
                return;
            }

            if (liczba_iteracji_textBox.Text.Length == 0)
            {
                MessageBox.Show("Podaj liczbe iteracji!", "Blad", MessageBoxButtons.OK);
                return;
            }

            // Preparation and launch of the algorithm
            int neuronCount = Convert.ToInt32(liczba_neuronow_textBox.Text);

            som = new SOM(neuronCount, shape, Int32.Parse(promien_sasiedztwa_textBox.Text));

            som.RandomNeurons();
            shape.Draw(som_pictureBox);

            List <Point> neurony = som.ReturnNeuronList();

            for (int i = 0; i < neurony.Count - 1; i++)
            {
                if (i == 0)
                {
                    DrawPoint(neurony[i].X, neurony[i].Y, Brushes.Black);
                }
                DrawEdge(neurony[i], neurony[i + 1]);
                DrawPoint(neurony[i + 1].X, neurony[i + 1].Y, Brushes.Black);
            }

            if (som == null)
            {
                MessageBox.Show("Som nie zostal prawidlowo zainicjowany", "Blad", MessageBoxButtons.OK);
                return;
            }
            else if (som.ReturnNeuronCount() == 0)
            {
                MessageBox.Show("Podaj poprawna liczbe neuronow", "Blad", MessageBoxButtons.OK);
                return;
            }
            else if (wspolczynnik_uczenia_textBox.Text.Length == 0)
            {
                MessageBox.Show("Podaj wspolczynnik uczenia", "Blad", MessageBoxButtons.OK);
                return;
            }

            som.IterationCount = Convert.ToInt32(liczba_iteracji_textBox.Text);
            som.LearningRate   = double.Parse(wspolczynnik_uczenia_textBox.Text, System.Globalization.CultureInfo.InvariantCulture);

            som_progressBar.Value = 0;
            som.StartSOM(DrawSOM, som_progressBar);
        }