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); } }
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; }
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); }
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); }
/// <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); }
// симетрична різниця 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); }
// граничний обєднання 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); }
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); }
// альфа сума 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); }