Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Uczenie sieci
            // przygotowywanie danych
            this.Cursor = Cursors.WaitCursor;
            this.toolStripProgressBar1.Enabled = true;
            this.toolStripProgressBar1.Maximum = (int)this.numericUpDown2.Value;
            double [][] array;

            if (this.listBox1.SelectedIndices.Count == this.listBox3.SelectedIndices.Count)
                array = new double[this.dataGridView1.Rows.Count * 2][];
            else
                array = new double[this.dataGridView1.Rows.Count][];
            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                array[i] = new double[this.listBox1.SelectedIndices.Count];
                for (int j = 0; j < this.listBox1.SelectedIndices.Count; j++ )
                {
                    String tmp = this.dataGridView1.Rows[i].Cells[this.listBox1.SelectedIndices[j]].FormattedValue.ToString().Replace('.',',');
                    if(tmp == "")
                        tmp = "0,0";
                    array[i][j] = double.Parse(tmp);
                }
            }

            if (this.listBox1.SelectedIndices.Count == this.listBox3.SelectedIndices.Count)
            {
                for (int i = this.dataGridView1.Rows.Count; i < this.dataGridView1.Rows.Count * 2; i++)
                {
                    array[i] = new double[this.listBox3.SelectedIndices.Count];
                    for (int j = 0; j < this.listBox3.SelectedIndices.Count; j++)
                    {
                        String tmp = this.dataGridView1.Rows[i - this.dataGridView1.Rows.Count].Cells[this.listBox3.SelectedIndices[j]].FormattedValue.ToString().Replace('.', ',');
                        if (tmp == "")
                            tmp = "0,0";
                        array[i][j] = double.Parse(tmp);
                    }
                }
            }

            // tworzenie sieci neuronowej
            this.som = new SOM((int)this.numericUpDown1.Value, (int)this.listBox1.SelectedItems.Count, double.Parse(this.textBox1.Text, CultureInfo.InvariantCulture), double.Parse(this.textBox2.Text, CultureInfo.InvariantCulture));

            // uczenie sieci
            this.som.uczsiec(array, (int)this.numericUpDown2.Value, this.toolStripProgressBar1);

            // sprzątanie
            this.richTextBox1.Text = this.som.ToString();
            this.toolStripProgressBar1.Value = 0;
            this.toolStripProgressBar1.Enabled = false;
            this.Cursor = Cursors.Default;
            this.toolStripButton3.Enabled = true;
        }
Пример #2
0
 private void toolStripButton2_Click(object sender, EventArgs e)
 {
     // Wczytywanie sieci
     DialogResult result = openFileDialog2.ShowDialog();
     if (result == DialogResult.OK)
     {
         this.som_file_name = this.openFileDialog2.FileName;
         this.som = SOM.wczytajsiec(this.som_file_name);
         this.numericUpDown1.Value = this.som.neurony.Length;
         this.textBox1.Text = this.som.wsp_uczenia.ToString();
         this.textBox2.Text = this.som.promien.ToString();
     }
     this.toolStripButton3.Enabled = true;
 }