Example #1
0
        private void создатьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            double left  = 0;
            double right = 0;
            double step  = 0;
            ContinuousFuzzySet <double, double> ConSet = null;
            DiscreteFuzzyStringSet DiscSet             = null;
            Params p = new Params();

            if (radioButton2.Checked)
            {
                try
                {
                    if (comboBox1.SelectedIndex == 1 ||
                        comboBox1.SelectedIndex == 0)
                    {
                        p.TryParse(textBox5.Text, textBox6.Text);
                    }
                    else if (comboBox1.SelectedIndex == 2)
                    {
                        p.TryParse(textBox5.Text, textBox6.Text, textBox7.Text);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Неверный аргумент!", "Ошибка");
                    return;
                }
                try
                {
                    Double.TryParse(textBox1.Text, out left);
                    Double.TryParse(textBox2.Text, out right);
                    Double.TryParse(textBox3.Text, out step);
                }
                catch (Exception)
                {
                    MessageBox.Show("Неверный аргумент!", "Ошибка");
                    return;
                }
                ConSet = CreateContinuousSet(left, right, step, p.a, p.b, p.c);
                ElementsCache.Add(ConSet);
            }
            else if (radioButton1.Checked)
            {
                string[] src = textBox4.Text.Split(new string[] { " ", ".", ",", ":", "\r\n" },
                                                   StringSplitOptions.RemoveEmptyEntries);
                if (comboBox2.SelectedIndex < 0 && comboBox3.SelectedIndex < 0 &&
                    comboBox4.SelectedIndex < 0 && comboBox1.SelectedIndex != 3)
                {
                    MessageBox.Show("Неверный аргумент!", "Ошибка");
                    return;
                }
                DiscSet = CreateDiscreteStringSet(comboBox2.SelectedIndex,
                                                  comboBox3.SelectedIndex, comboBox4.SelectedIndex, src);
                ElementsCache.Add(DiscSet);
            }
            listBox1.Items.Add("set #" + ElementsCache.Count.ToString());
        }
Example #2
0
        private void графикToolStripMenuItem_Click(object sender, EventArgs e)
        {
            chart1.ResetAutoValues();
            int id = listBox1.SelectedIndex;
            ContinuousFuzzySet <double, double> ConSet = null;
            DiscreteFuzzyStringSet DiskSet             = null;

            if (ElementsCache.GetAt(id).GetType() == typeof(ContinuousFuzzySet <double, double>))
            {
                ConSet = (ContinuousFuzzySet <double, double>)ElementsCache.GetAt(id);
                ViewSet(ConSet, chart1);
            }
            else if (ElementsCache.GetAt(id).GetType() == typeof(DiscreteFuzzyStringSet))
            {
                DiskSet = (DiscreteFuzzyStringSet)ElementsCache.GetAt(id);
                ViewSet(DiskSet, chart1);
            }
        }
Example #3
0
        private DiscreteFuzzyStringSet CreateDiscreteStringSet(double a, double b, double c, string[] src)
        {
            DiscreteFuzzyStringSet set = null;

            switch (comboBox1.SelectedIndex)
            {
            case (int)FunctionTypes.SFunction:
                FuzzySetCreator <double, double> .MemberShipFunction3 Sfunc =
                    new FuzzySetCreator <double, double> .MemberShipFunction3(FuzzyHelper.SFunction);

                set = FuzzySetCreator <double, double> .CreateInstance(Sfunc, a, b, src);

                break;

            case (int)FunctionTypes.ZFunction:
                FuzzySetCreator <double, double> .MemberShipFunction3 Zfunc =
                    new FuzzySetCreator <double, double> .MemberShipFunction3(FuzzyHelper.ZFunction);

                set = FuzzySetCreator <double, double> .CreateInstance(Zfunc, a, b, src);

                break;

            case (int)FunctionTypes.PFunction:
                FuzzySetCreator <double, double> .MemberShipFunction4 Pfunc =
                    new FuzzySetCreator <double, double> .MemberShipFunction4(FuzzyHelper.PFunction);

                set = FuzzySetCreator <double, double> .CreateInstance(Pfunc, a, b, c, src);

                break;

            case (int)FunctionTypes.Custom:
                List <KeyValuePair <string, double> > list = ReadFromText(textBox4);
                set = FuzzySetCreator <string, double> .CreateInstance(list);

                break;
            }
            return(set);
        }