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(); }
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(); }