Пример #1
0
 public static FuzzySet1D operator &(FuzzySet1D f1, FuzzySet1D f2)
 {
     if ((!f1.discrete && f2.discrete) || (f1.discrete && !f2.discrete))
     {
         MessageBox.Show("Операцію перетину можна робити тільки над множинами одного типу");
         return(null);
     }
     if (f1.discrete && f2.discrete)
     {
         FuzzySet1D res = new FuzzySet1D();
         foreach (KeyValuePair <double, double> pair in f1.dots)
         {
             res.AddDot(pair.Key, Math.Min(pair.Value, f2.Mu(pair.Key)));
         }
         foreach (KeyValuePair <double, double> pair in f2.dots)
         {
             res.AddDot(pair.Key, Math.Min(pair.Value, f1.Mu(pair.Key)));
         }
         return(res);
     }
     else
     {
         FuzzySet1D res = new FuzzySet1D();
         res.Discrete = false;
         foreach (KeyValuePair <double, double> pair in f1.dots)
         {
             res.AddDot(pair.Key, Math.Min(pair.Value, f2.Mu(pair.Key)));
         }
         return(res);
     }
 }
Пример #2
0
 public FuzzySet1D(FuzzySet1D set) : this()
 {
     this.Name = set.Name;
     foreach (KeyValuePair <double, double> pair in set.Dots)
     {
         this.dots.Add(pair.Key, pair.Value);
     }
     this.discrete = set.discrete;
 }
Пример #3
0
        public static FuzzySet1D operator /(FuzzySet1D f1, FuzzySet1D f2)
        {
            FuzzySet1D res = new FuzzySet1D();

            foreach (KeyValuePair <double, double> pair in f1.dots)
            {
                res.AddDot(pair.Key, Math.Max(pair.Value - f2.Mu(pair.Key), 0));
            }
            return(res);
        }
Пример #4
0
        public static FuzzySet1D CreateTriangle(double d, double s, double h)
        {
            FuzzySet1D fs = new FuzzySet1D();

            fs.Discrete = false;

            for (int i = 0; i < FuzzySet.maxDotCount; i++)
            {
                double x = 1.0 * i * (FuzzySet.toX - FuzzySet.fromX) / FuzzySet.maxDotCount + fromX;
                fs.AddDot(x, pTriangle(x, d, s, h));
            }
            return(fs);
        }
Пример #5
0
        /// <summary>
        /// создает нечеткое множество, определяющее нормальную функцию распределения
        /// </summary>
        /// <param name="m">Мат ожидание</param>
        /// <param name="s">Корень из дисперсии</param>
        /// <returns></returns>
        public static FuzzySet1D CreateNormalDistribution(double m, double s)
        {
            FuzzySet1D fs = new FuzzySet1D();

            fs.Discrete = false;

            for (int i = 0; i < FuzzySet.maxDotCount; i++)
            {
                double x = 1.0 * i * (FuzzySet.toX - FuzzySet.fromX) / FuzzySet.maxDotCount + fromX;
                fs.AddDot(x, pNormalDiscr(x, m, s));
            }
            return(fs);
        }
Пример #6
0
        // симетрична різниця
        public static FuzzySet1D operator -(FuzzySet1D f1, FuzzySet1D f2)
        {
            FuzzySet1D res = new FuzzySet1D();

            foreach (KeyValuePair <double, double> pair in f1.dots)
            {
                double x = pair.Key;
                res.AddDot(pair.Key, Math.Abs(f1.Mu(x) - f2.Mu(x)));
            }
            foreach (KeyValuePair <double, double> pair in f2.dots)
            {
                double x = pair.Key;
                res.AddDot(pair.Key, Math.Abs(f1.Mu(x) - f2.Mu(x)));
            }
            return(res);
        }
Пример #7
0
        // граничний обєднання
        public static FuzzySet1D gUnion(FuzzySet1D f1, FuzzySet1D f2)
        {
            FuzzySet1D res = new FuzzySet1D();

            foreach (KeyValuePair <double, double> pair in f1.dots)
            {
                double x = pair.Key;
                res.AddDot(pair.Key, Math.Min(f1.Mu(x) + f2.Mu(x), 1));
            }
            foreach (KeyValuePair <double, double> pair in f2.dots)
            {
                double x = pair.Key;
                res.AddDot(pair.Key, Math.Min(f1.Mu(x) + f2.Mu(x), 1));
            }
            return(res);
        }
Пример #8
0
        public static FuzzySet1D operator /(FuzzySet1D f1, FuzzySet1D f2)
        {
            if ((!f1.discrete && f2.discrete) || (f1.discrete && !f2.discrete))
            {
                MessageBox.Show("Операцію різниці можна робити тільки над множинами одного типу");
                return(null);
            }
            FuzzySet1D res = new FuzzySet1D();

            foreach (KeyValuePair <double, double> pair in f1.dots)
            {
                if (pair.Value - f2.Mu(pair.Key) > 0)
                {
                    res.AddDot(pair.Key, pair.Value - f2.Mu(pair.Key));
                }
            }
            res.discrete = f1.discrete;
            return(res);
        }
Пример #9
0
        // альфа сума
        public static FuzzySet1D alphaSum(FuzzySet1D f1, FuzzySet1D f2, double alpha)
        {
            FuzzySet1D res = new FuzzySet1D();

            if (alpha > 1)
            {
                alpha = 1;
            }
            foreach (KeyValuePair <double, double> pair in f1.dots)
            {
                double x = pair.Key;
                res.AddDot(pair.Key, alpha * f1.Mu(x) + (1 - alpha) * f2.Mu(x));
            }
            foreach (KeyValuePair <double, double> pair in f2.dots)
            {
                double x = pair.Key;
                res.AddDot(pair.Key, alpha * f1.Mu(x) + (1 - alpha) * f2.Mu(x));
            }
            return(res);
        }