Exemplo n.º 1
0
 private void fourthToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dgwSets.SelectedRows.Count != 2)
     {
         return;
     }
     if ((dgwSets.SelectedRows[0].Tag as FuzzySet).Discrete != (dgwSets.SelectedRows[1].Tag as FuzzySet).Discrete)
     {
         return;
     }
     if (dgwSets.SelectedRows[0].Tag.GetType() != dgwSets.SelectedRows[1].Tag.GetType())
     {
         return;
     }
     if (dgwSets.SelectedRows[0].Tag is FuzzySet1D)
     {
         FuzzySet1D set = (dgwSets.SelectedRows[0].Tag as FuzzySet1D) / (dgwSets.SelectedRows[1].Tag as FuzzySet1D);
         sets.Add(set);
     }
     if (dgwSets.SelectedRows[0].Tag is FuzzySet2D)
     {
         FuzzySet2D set = (dgwSets.SelectedRows[0].Tag as FuzzySet2D) / (dgwSets.SelectedRows[1].Tag as FuzzySet2D);
         sets.Add(set);
     }
     UpdateListToDgw();
 }
Exemplo n.º 2
0
 private void tbDotDel_Click(object sender, EventArgs e)
 {
     if (!(dgwItems.Tag as FuzzySet).Discrete)
     {
         return;
     }
     if (dgwItems.Tag is FuzzySet1D)
     {
         FuzzySet1D set = dgwItems.Tag as FuzzySet1D;
         foreach (DataGridViewRow row in dgwItems.SelectedRows)
         {
             set.RemoveDot(double.Parse(row.Cells[0].Value.ToString()));
         }
         set.ToMatrix(dgwItems);
         pGraph.Tag = set.Render(pGraph.Size);
         pGraph.Invalidate();
     }
     if (dgwItems.Tag is FuzzySet2D)
     {
         FuzzySet2D set = dgwItems.Tag as FuzzySet2D;
         foreach (DataGridViewCell cell in dgwItems.SelectedCells)
         {
             if (dgwItems.Columns[cell.ColumnIndex].Tag != null && dgwItems.Rows[cell.RowIndex].Tag != null)
             {
                 set.RemoveDot((double)dgwItems.Columns[cell.ColumnIndex].Tag, (double)dgwItems.Rows[cell.RowIndex].Tag);
             }
         }
         set.ToMatrix(dgwItems);
         pGraph.Tag = set.Render(pGraph.Size);
         pGraph.Invalidate();
     }
 }
Exemplo n.º 3
0
        private void неперервнаToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            FuzzySet2D fs = new FuzzySet2D();

            fs.Discrete = false;
            sets.Add(fs);
            UpdateListToDgw();
        }
Exemplo n.º 4
0
        private void перетинToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dgwSets.SelectedRows.Count == 0)
            {
                return;
            }
            if (dgwSets.SelectedRows.Count == 1)
            {
                sets.Add(new FuzzySet1D(dgwSets.SelectedRows[0].Tag as FuzzySet1D));
            }

            else
            {
                for (int i = 1; i < dgwSets.SelectedRows.Count; i++)
                {
                    if ((dgwSets.SelectedRows[i].Tag as FuzzySet).Discrete != (dgwSets.SelectedRows[0].Tag as FuzzySet).Discrete)
                    {
                        return;
                    }
                }
                for (int i = 1; i < dgwSets.SelectedRows.Count; i++)
                {
                    if (((dgwSets.SelectedRows[i].Tag is FuzzySet1D) && (dgwSets.SelectedRows[0].Tag is FuzzySet2D)) ||
                        ((dgwSets.SelectedRows[i].Tag is FuzzySet2D) && (dgwSets.SelectedRows[0].Tag is FuzzySet1D)))
                    {
                        return;
                    }
                }
                if (dgwSets.SelectedRows[0].Tag is FuzzySet1D)
                {
                    FuzzySet1D set = (dgwSets.SelectedRows[0].Tag as FuzzySet1D) & (dgwSets.SelectedRows[1].Tag as FuzzySet1D);
                    for (int i = 2; i < dgwSets.SelectedRows.Count; i++)
                    {
                        set = set & (dgwSets.SelectedRows[i].Tag as FuzzySet1D);
                    }
                    sets.Add(set);
                }
                if (dgwSets.SelectedRows[0].Tag is FuzzySet2D)
                {
                    FuzzySet2D set = (dgwSets.SelectedRows[0].Tag as FuzzySet2D) & (dgwSets.SelectedRows[1].Tag as FuzzySet2D);
                    for (int i = 2; i < dgwSets.SelectedRows.Count; i++)
                    {
                        set = set & (dgwSets.SelectedRows[i].Tag as FuzzySet2D);
                    }
                    sets.Add(set);
                }
            }
            UpdateListToDgw();
        }
Exemplo n.º 5
0
 private void максимультипликативнаToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dgwSets.SelectedRows.Count != 2)
     {
         return;
     }
     if (dgwSets.SelectedRows[0].Tag is FuzzySet1D || dgwSets.SelectedRows[1].Tag is FuzzySet1D)
     {
         return;
     }
     if (dgwSets.SelectedRows[0].Tag is FuzzySet2D)
     {
         FuzzySet2D set = FuzzySet2D.MaxMultCompose(dgwSets.SelectedRows[0].Tag as FuzzySet2D, dgwSets.SelectedRows[1].Tag as FuzzySet2D);
         sets.Add(set);
     }
     UpdateListToDgw();
 }
Exemplo n.º 6
0
        private void nineToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dgwSets.SelectedRows.Count != 2)
            {
                return;
            }
            if (!(dgwSets.SelectedRows[0].Tag is FuzzySet1D) || !(dgwSets.SelectedRows[1].Tag is FuzzySet1D))
            {
                return;
            }
            if (!(dgwSets.SelectedRows[0].Tag as FuzzySet1D).Discrete || !(dgwSets.SelectedRows[1].Tag as FuzzySet1D).Discrete)
            {
                return;
            }
            FuzzySet2D res = (dgwSets.SelectedRows[0].Tag as FuzzySet1D) * (dgwSets.SelectedRows[1].Tag as FuzzySet1D);

            sets.Add(res);
            UpdateListToDgw();
        }
Exemplo n.º 7
0
 private void btnDFormula_Click(object sender, EventArgs e)
 {
     if (dgwItems.Tag == null)
     {
         return;
     }
     if (dgwItems.Tag is FuzzySet1D)
     {
         FuzzySet1D set = dgwItems.Tag as FuzzySet1D;
         double     x   = 0.0;
         try
         {
             x = double.Parse(tbMuX.Text);
         }
         catch
         {
             tbMuX.Text = "";
             return;
         }
         tbMuRes.Text = set.Mu(x).ToString();
     }
     else
     {
         FuzzySet2D set = dgwItems.Tag as FuzzySet2D;
         double     x   = 0.0;
         double     y   = 0.0;
         try
         {
             x = double.Parse(tbMuX1.Text);
             y = double.Parse(tbMuX2.Text);
         }
         catch
         {
             tbMuX1.Text = "";
             tbMuX2.Text = "";
             return;
         }
         tbMuRes.Text = set.Mu(x, y).ToString();
     }
 }
Exemplo n.º 8
0
        private void Y()
        {
            if (cTk.Type != Token.MULT && cTk.Type != Token.COMPOS)
            {
                return;
            }
            int tType = cTk.Type;

            GetToken();
            F();
            if (tType == Token.MULT)
            {
                FuzzySet1D s1 = stack.Pop() as FuzzySet1D;
                FuzzySet1D s2 = stack.Pop() as FuzzySet1D;
                if (s1 == null || s2 == null)
                {
                    throw new SemError("Декартів добуток для двовимірних нечітких множин не визначено");
                }
                FuzzySet2D res = s1 * s2;
                if (res != null)
                {
                    stack.Push(s1 * s2);
                }
                else
                {
                    throw new SemError("Помилка при декартовому добутку");
                }
            }
            if (tType == Token.COMPOS)
            {
                FuzzySet2D s1 = stack.Pop() as FuzzySet2D;
                FuzzySet2D s2 = stack.Pop() as FuzzySet2D;
                if (s1 == null || s2 == null)
                {
                    throw new SemError("Композиція визначена тільки для двовимірних множин");
                }
                stack.Push(FuzzySet2D.MaxMinCompose(s1, s2));
            }
            Y();
        }
Exemplo n.º 9
0
 private void btnAddDot_Click(object sender, EventArgs e)
 {
     if (!(dgwItems.Tag as FuzzySet).Discrete)
     {
         return;
     }
     if (dgwItems.Tag is FuzzySet1D)
     {
         FuzzySet1D set = dgwItems.Tag as FuzzySet1D;
         try
         {
             double x = double.Parse(tbDotX1.Text);
             double y = double.Parse(tbDotX2.Text);
             set.AddDot(x, y);
         }
         catch { return; }
         set.ToMatrix(dgwItems);
         pGraph.Tag = set.Render(pGraph.Size);
         pGraph.Invalidate();
     }
     if (dgwItems.Tag is FuzzySet2D)
     {
         FuzzySet2D set = dgwItems.Tag as FuzzySet2D;
         try
         {
             double x = double.Parse(tbDotX1.Text);
             double y = double.Parse(tbDotX2.Text);
             double z = double.Parse(tbDotX3.Text);
             set.RemoveDot(x, y);
             set.AddDot(x, y, z);
         }
         catch { return; }
         set.ToMatrix(dgwItems);
         pGraph.Tag = set.Render(pGraph.Size);
         pGraph.Invalidate();
     }
 }
Exemplo n.º 10
0
        public frmModule()
        {
            InitializeComponent();
            #region Dgw & List
            sets = new List <FuzzySet>();
            dgwSets.DataSource = null;
            dgwSets.Columns.Clear();
            {
                DataGridViewColumn col = new DataGridViewTextBoxColumn();
                col.ValueType    = typeof(string);
                col.Name         = "Name";
                col.HeaderText   = Properties.Resources.Name;
                col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                col.ReadOnly     = false;
                col.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                dgwSets.Columns.Add(col);
            }
            {
                DataGridViewColumn col = new DataGridViewTextBoxColumn();
                col.ValueType    = typeof(string);
                col.Name         = "Dimension";
                col.HeaderText   = Properties.Resources.Dimension;
                col.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                col.ReadOnly     = true;
                col.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                dgwSets.Columns.Add(col);
            }
            #endregion
#if DEBUG
            {
                FuzzySet1D fs = new FuzzySet1D();
                fs.Name = "A";
                fs.AddDot(1.0, 1.0);
                fs.AddDot(2.0, 0.3);
                fs.AddDot(2.5, 0.4);
                fs.AddDot(3.0, 0.7);
                sets.Add(fs);
            }
            {
                FuzzySet1D fs = new FuzzySet1D();
                fs.Name = "B";
                fs.AddDot(1.0, 0.2);
                fs.AddDot(3.0, 0.1);
                fs.AddDot(4.0, 0.3);
                fs.AddDot(5.0, 0.4);
                sets.Add(fs);
            }
            {
                FuzzySet1D fs = new FuzzySet1D();
                fs.Name = "C";
                fs.AddDot(1.0, 0.1);
                fs.AddDot(3.0, 0.1);
                fs.AddDot(4.0, 0.1);
                fs.AddDot(5.0, 0.1);
                sets.Add(fs);
            }
            {
                FuzzySet1D fs = new FuzzySet1D();
                fs.Name = "D";
                fs.AddDot(1.0, 0.5);
                fs.AddDot(3.0, 0.5);
                fs.AddDot(4.0, 0.5);
                fs.AddDot(5.0, 0.5);
                sets.Add(fs);
            }
            {
                FuzzySet2D fs = new FuzzySet2D();
                fs.Name = "E";
                fs.AddDot(1.0, 1.0, 0.5);
                fs.AddDot(3.0, 3.0, 0.5);
                fs.AddDot(4.0, 4.0, 0.5);
                fs.AddDot(5.0, 5.0, 0.5);
                sets.Add(fs);
            }
            {
                FuzzySet2D fs = new FuzzySet2D();
                fs.Name = "F";
                fs.AddDot(1.0, 0.3, 0.3);
                fs.AddDot(3.0, 1.7, 0.1);
                fs.AddDot(4.0, 3.6, 0.3);
                fs.AddDot(5.0, 8.0, 0.7);
                sets.Add(fs);
            }
#endif
            UpdateListToDgw();
        }