Exemplo n.º 1
0
        private void button5_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndices.Count != 3)
            {
                MessageBox.Show("Нужно выбрать 3 множества!", "Сообщение");
                return;
            }
            int id = listBox1.SelectedIndices[0];
            ContinuousFuzzySet <double, double> A =
                (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(id);

            id = listBox1.SelectedIndices[1];
            ContinuousFuzzySet <double, double> B =
                (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(id);

            id = listBox1.SelectedIndices[2];
            ContinuousFuzzySet <double, double> C =
                (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(id);

            if (A.Cardinality() + B.Cardinality()
                + C.Cardinality() != 3 * A.Cardinality())
            {
                MessageBox.Show("Sets must have equals cardinality!!!", "Message");
                return;
            }
            ContinuousFuzzySet <double, double> L = null;
            ContinuousFuzzySet <double, double> R = null;

            ViewSet(A, "Set A", chart11);
            ViewSet(B, "Set B", chart12);
            ViewSet(FuzzyOperations.Inversion(B),
                    "not(B)", chart13);
            ViewSet(C, "Set C", chart14);
            ContinuousFuzzySet <double, double> Q =
                FuzzyOperations.Sum(C, FuzzyOperations.Inversion(B));

            ViewSet(Q, "not(B) + C", chart15);
            L = FuzzyOperations.Multiply(A, Q);
            ViewSet(L, "A * (not(B) + C)", chart16);
            ContinuousFuzzySet <double, double> Op1 =
                FuzzyOperations.Multiply(A, FuzzyOperations.Inversion(B));
            ContinuousFuzzySet <double, double> Op2 =
                FuzzyOperations.Multiply(A, C);

            ViewSet(Op1, "A * not(B)", chart17);
            ViewSet(Op2, "A * C", chart18);
            R = FuzzyOperations.Sum(Op1, Op2);
            ViewSet(R, "(A*not(B)+(A*C)", chart19);
            double d1 = FuzzySetDescriptor.EuclidianDistance(L, R);
            double d2 = FuzzySetDescriptor.HammingDistance(L, R);

            label8.Text = "Расстояние Эвклида: " + d1.ToString();
            label9.Text = "Расстояние Хемминга: " + d2.ToString();
        }
Exemplo n.º 2
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndices.Count != 2)
            {
                MessageBox.Show("Нужно выбрать 2 множества!", "Сообщение");
                return;
            }
            int id = listBox1.SelectedIndices[0];
            ContinuousFuzzySet <double, double> A =
                (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(id);

            id = listBox1.SelectedIndices[1];
            ContinuousFuzzySet <double, double> B =
                (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(id);

            if (A.Cardinality() != B.Cardinality())
            {
                MessageBox.Show("Sets must have equals cardinality!!!", "Message");
                return;
            }
            ContinuousFuzzySet <double, double> Op1 = null;
            ContinuousFuzzySet <double, double> Op2 = null;

            ViewSet(A, "Set A", chart2);
            ViewSet(B, "Set B", chart3);
            ContinuousFuzzySet <double, double> C =
                FuzzyOperations.Sum(A, B);

            Op1 = FuzzyOperations.Inversion(C);
            ViewSet(C, "A + B", chart4);
            ViewSet(Op1, "not(A + B)", chart5);
            ViewSet(A, "Set A", chart6);
            ViewSet(B, "Set B", chart7);
            ViewSet(FuzzyOperations.Inversion(A), "not(A)", chart8);
            ViewSet(FuzzyOperations.Inversion(B), "not(B)", chart9);
            Op2 = FuzzyOperations.Multiply(FuzzyOperations.Inversion(A),
                                           FuzzyOperations.Inversion(B));
            ViewSet(Op2, "not(A) * not(B)", chart10);
            double d1 = FuzzySetDescriptor.EuclidianDistance(Op1, Op2);
            double d2 = FuzzySetDescriptor.HammingDistance(Op1, Op2);

            label6.Text = "Расстояние Эвклида: " + d1.ToString();
            label7.Text = "Расстояние Хемминга: " + d2.ToString();
        }
Exemplo n.º 3
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex < 0)
     {
         return;
     }
     ListBox.SelectedIndexCollection items = listBox1.SelectedIndices;
     textBox6.Text = string.Empty;
     for (int i = 0; i < items.Count; i++)
     {
         ContinuousFuzzySet <double, double> set =
             (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(i);
         double val = FuzzySetDescriptor.Entropy(set);
         textBox6.AppendText("Энтропия множества #" + i.ToString() + ": " +
                             val.ToString() + "\r\n");
     }
     for (int i = 0; i < items.Count; i++)
     {
         for (int j = i + 1; j < items.Count; j++)
         {
             textBox6.AppendText("Эвклидово расстояние между "
                                 + (i + 1).ToString() + " и " + (j + 1).ToString() + ": ");
             ContinuousFuzzySet <double, double> set1 =
                 (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(i);
             ContinuousFuzzySet <double, double> set2 =
                 (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(j);
             if (set1.Cardinality() != set2.Cardinality())
             {
                 textBox6.AppendText("Sets must have equals cardinality!!!");
                 return;
             }
             double distance = 0;
             distance = FuzzySetDescriptor.EuclidianDistance(set1, set2);
             textBox6.AppendText(distance.ToString() + "\r\n");
             textBox6.AppendText("Расстояние Хемминга между "
                                 + (i + 1).ToString() + " и " + (j + 1).ToString() + ": ");
             distance = FuzzySetDescriptor.HammingDistance(set1, set2);
             textBox6.AppendText(distance.ToString() + "\r\n");
         }
     }
 }