예제 #1
0
        private void fuzzyDataGridViewRules_Loader(FuzzyRuleSet _frsFuzzyRuleSet)
        {
            int irows = _frsFuzzyRuleSet.Rules.GetLength(0);
            int icolumns = _frsFuzzyRuleSet.Rules.GetLength(1);

            for (int i = 0; i < irows; i++)
            {
                DataGridViewRow dgvrow = new DataGridViewRow();
                DataGridViewTextBoxCell celltextbox = new DataGridViewTextBoxCell();
                celltextbox.Value = i + 1;
                dgvrow.Cells.Add(celltextbox);
                for (int j=0; j < icolumns-2; j++)
                {
                    DataGridViewCheckBoxCell cellcheckbox = new DataGridViewCheckBoxCell();
                    DataGridViewComboBoxCell cellcombobox = new DataGridViewComboBoxCell();
                    if (_frsFuzzyRuleSet.Rules[i, j] < 0) cellcheckbox.Value = 1;
                    int index = Math.Abs(Convert.ToInt32(_frsFuzzyRuleSet.Rules[i, j]));
                    if (j < _frsFuzzyRuleSet.Inputs.Count)
                    {
                        cellcombobox.Items.Add("<none>");
                        foreach (FuzzyMF mf in _frsFuzzyRuleSet.Inputs[j].MFs)
                        {
                            cellcombobox.Items.Add(mf.Name.ToString());
                        }
                        if (index != 0) cellcombobox.Value = _frsFuzzyRuleSet.Inputs[j].MFs[index - 1].Name.ToString();
                        else cellcombobox.Value = "<none>";
                    }
                    else
                    {
                        cellcombobox.Items.Add("<none>");
                        foreach (FuzzyMF mf in _frsFuzzyRuleSet.Outputs[j - _frsFuzzyRuleSet.Inputs.Count].MFs)
                        {
                            cellcombobox.Items.Add(mf.Name.ToString());
                        }
                        if(index != 0) cellcombobox.Value = _frsFuzzyRuleSet.Outputs[j - _frsFuzzyRuleSet.Inputs.Count].MFs[index-1].Name.ToString();
                        else cellcombobox.Value = "<none>";
                    }
                    dgvrow.Cells.AddRange(cellcheckbox, cellcombobox);
                }
                DataGridViewComboBoxCell cellcombobox_connection = new DataGridViewComboBoxCell();
                cellcombobox_connection.Items.AddRange("AND", "OR");
                if (_frsFuzzyRuleSet.Rules[i, icolumns - 1] == 1) cellcombobox_connection.Value = "AND";
                else if(_frsFuzzyRuleSet.Rules[i, icolumns - 1] == 2) cellcombobox_connection.Value = "OR";
                DataGridViewComboBoxCell cellcombobox_weight = new DataGridViewComboBoxCell();
                cellcombobox_weight.Items.AddRange(new object[] {"0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1"});
                cellcombobox_weight.Value = Convert.ToString(_frsFuzzyRuleSet.Rules[i, icolumns - 2], System.Globalization.CultureInfo.InvariantCulture);
                dgvrow.Cells.AddRange(cellcombobox_connection, cellcombobox_weight);
                this.fuzzyDataGridView.Rows.Add(dgvrow);
                this.numberOfRulesNumericUpDown.Enabled = true;
            }
        }
예제 #2
0
        private void fuzzyDataGridView_Loader(FuzzyRuleSet _frsFuzzyRuleSet)
        {
            int icolumn = _frsFuzzyRuleSet.Inputs.Count*2 + _frsFuzzyRuleSet.Outputs.Count*2 + 3;
            DataGridViewColumn[] dgvcA = new DataGridViewColumn[icolumn];

            dgvcA[0] = new DataGridViewTextBoxColumn();
            dgvcA[0].HeaderText = "Rules";
            dgvcA[0].MinimumWidth = 40;
            dgvcA[0].Name = "RulesColumn";
            dgvcA[0].ReadOnly = true;
            int i = 0;
            foreach (FuzzyIO Input in _frsFuzzyRuleSet.Inputs)
            {
                i++;
                dgvcA[i] = new DataGridViewCheckBoxColumn();
                dgvcA[i].HeaderText = "not";
                dgvcA[i].MinimumWidth = 30;
                dgvcA[i].Name = "not" + Input.Name;
                i++;
                dgvcA[i] = new DataGridViewComboBoxColumn();
                dgvcA[i].HeaderText = Input.Name;
                dgvcA[i].Name = Input.Name;
                dgvcA[i].MinimumWidth = 100;
                ((DataGridViewComboBoxColumn)dgvcA[i]).Items.Add("<none>");
                foreach (FuzzyMF mf in Input.MFs)
                {
                    ((DataGridViewComboBoxColumn)dgvcA[i]).Items.Add(mf.Name);
                }
            }
            foreach (FuzzyIO Output in _frsFuzzyRuleSet.Outputs)
            {
                i++;
                dgvcA[i] = new DataGridViewCheckBoxColumn();
                dgvcA[i].HeaderText = "not";
                dgvcA[i].MinimumWidth = 30;
                dgvcA[i].Name = "not" + Output.Name;
                i++;
                dgvcA[i] = new DataGridViewComboBoxColumn();
                dgvcA[i].HeaderText = Output.Name;
                dgvcA[i].Name = Output.Name;
                dgvcA[i].MinimumWidth = 100;
                ((DataGridViewComboBoxColumn)dgvcA[i]).Items.Add("<none>");
                foreach (FuzzyMF mf in Output.MFs)
                {
                    ((DataGridViewComboBoxColumn)dgvcA[i]).Items.Add(mf.Name);
                }
            }
            i++;
            dgvcA[i] = new DataGridViewComboBoxColumn();
            dgvcA[i].HeaderText = "Connection";
            ((DataGridViewComboBoxColumn)dgvcA[i]).Items.AddRange(new object[] {
            "AND",
            "OR"});
            dgvcA[i].MinimumWidth = 100;
            dgvcA[i].Name = "connectionColumn";
            i++;
            dgvcA[i] = new DataGridViewComboBoxColumn();
            dgvcA[i].HeaderText = "Weight";
            ((DataGridViewComboBoxColumn)dgvcA[i]).Items.AddRange(new object[] { "0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1",});
            dgvcA[i].MinimumWidth = 100;
            dgvcA[i].Name = "weightColumn";

            this.fuzzyDataGridView.SuspendLayout();
            this.fuzzyDataGridView.Columns.Clear();
            this.fuzzyDataGridView.Columns.AddRange(dgvcA);
            this.fuzzyDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            this.fuzzyDataGridView.ResumeLayout();
            this.fuzzyDataGridView.PerformLayout();
        }
예제 #3
0
 private void fisOpenFileDialog_FileOk(object sender, CancelEventArgs e)
 {
     this.FISFuzzyRuleSet = new FuzzyRuleSet();
     fisOpenBackgroundWorker.RunWorkerAsync(this.fisOpenFileDialog.FileName);
 }