Exemple #1
0
        public static FuzzyNumber BinaryOperation(FuzzyNumber A, FuzzyNumber B, Func <double, double, double> op)
        {
            if (A.Domain != B.Domain)
            {
                throw new ArgumentException("Домены должны совпадать");
            }
            var dom    = A.Domain;
            var result = new FuzzyNumber(dom);

            foreach (var a in dom.Arguments)
            {
                foreach (var b in dom.Arguments)
                {
                    var value = op(a, b);
                    if (!dom.Contains(value))
                    {
                        continue;
                    }
                    result[value] = dom.S(result[value], dom.T(A[a], B[b]));
                }
            }

            for (int k = 0; k < 3; k++)
            {
                foreach (var e in dom.Arguments)
                {
                    if (!dom.Contains(e + dom.Precision) || !dom.Contains(e - dom.Precision))
                    {
                        continue;
                    }
                    result[e] = (result[e] + result[e + dom.Precision] + result[e - dom.Precision]) / 3;
                }
            }
            return(result);
        }
Exemple #2
0
        public FuzzyNumber NumberFromLambda(Func <double, double> lambda)
        {
            var result = new FuzzyNumber(this);

            foreach (var e in Arguments)
            {
                result[e] = lambda(e);
            }
            return(result);
        }
Exemple #3
0
 public FuzzyNumber Near(double near)
 {
     var result =  new FuzzyNumber(this);
     for (double x = Min; x <= Max; x += Precision)
     {
         var measure = NearFunction(x, near);
         if (measure > 0.001)
             result[x] = measure;
     }
     return result;
 }
Exemple #4
0
        public static FuzzyNumber Relation(Func <double, double, double> relation, FuzzyNumber argument)
        {
            FuzzyNumber number = new FuzzyNumber(argument.Domain);

            foreach (var x in argument.Domain.Arguments)
            {
                foreach (var y in argument.Domain.Arguments)
                {
                    number[y] = argument.Domain.S(number[y], argument.Domain.T(argument[x], relation(x, y)));
                }
            }
            return(number);
        }
Exemple #5
0
        public FuzzyNumber Near(double near)
        {
            var result = new FuzzyNumber(this);

            for (double x = Min; x <= Max; x += Precision)
            {
                var measure = NearFunction(x, near);
                if (measure > 0.001)
                {
                    result[x] = measure;
                }
            }
            return(result);
        }
Exemple #6
0
        public static FuzzyNumber SetOperation(FuzzyNumber A, FuzzyNumber B, Func <double, double, double> op)
        {
            if (A.Domain != B.Domain)
            {
                throw new ArgumentException("Домены должны совпадать");
            }
            var dom    = A.Domain;
            var result = new FuzzyNumber(dom);

            foreach (var x in dom.Arguments)
            {
                result[x] = op(A[x], B[x]);
            }
            return(result);
        }
Exemple #7
0
        public static FuzzyNumber BinaryOperation(FuzzyNumber A, FuzzyNumber B, Func<double,double,double> op)
        {
            if (A.Domain != B.Domain) throw new ArgumentException("Домены должны совпадать");
            var dom = A.Domain;
            var result = new FuzzyNumber(dom);

            foreach(var a in dom.Arguments)
                foreach (var b in dom.Arguments)
                {
                    var value = op(a, b);
                    if (!dom.Contains(value)) continue;
                    result[value] = dom.S(result[value], dom.T(A[a], B[b]));
                }

            for (int k = 0; k < 3; k++)
                foreach (var e in dom.Arguments)
                {
                    if (!dom.Contains(e + dom.Precision) || !dom.Contains(e - dom.Precision)) continue;
                    result[e] = (result[e] + result[e + dom.Precision] + result[e - dom.Precision]) / 3;
                }
            return result;
        }
Exemple #8
0
 static Func<double, double, double> GoguenImplication(FuzzyNumber from, FuzzyNumber to)
 {
     return (x,y) => { if (from[x]==0) return 1; else return Math.Min(1,to[y]/from[x]); };
 }
Exemple #9
0
 public FuzzyNumber NumberFromLambda(Func<double, double> lambda)
 {
     var result = new FuzzyNumber(this);
     foreach (var e in Arguments)
         result[e] = lambda(e);
     return result;
 }
Exemple #10
0
 public static FuzzyNumber Relation(Func<double, double, double> relation, FuzzyNumber argument)
 {
     FuzzyNumber number = new FuzzyNumber(argument.Domain);
     foreach (var x in argument.Domain.Arguments)
         foreach (var y in argument.Domain.Arguments)
             number[y] = argument.Domain.S(number[y], argument.Domain.T(argument[x], relation(x, y)));
     return number;
 }
Exemple #11
0
 public static FuzzyNumber SetOperation(FuzzyNumber A, FuzzyNumber B, Func<double,double,double> op)
 {
     if (A.Domain != B.Domain) throw new ArgumentException("Домены должны совпадать");
     var dom = A.Domain;
     var result=new FuzzyNumber(dom);
     foreach(var x in dom.Arguments)
         result[x] = op(A[x], B[x]);
     return result;
 }
 static void SavePlot(string Name, FuzzyNumber num)
 {
     using (var file = new StreamWriter(@"..\..\..\..\LaTeX\Plots\" + Name + ".txt"))
     {
         file.WriteLine("# N mu");
         foreach(var e in num.Domain.Arguments)
             if (Math.Abs(num[e]) > 0.01)
                 file.WriteLine("{0}\t{1}", DTS(e), DTS(num[e]));
     }
     using (var file = new StreamWriter(@"..\..\..\..\LaTeX\Plots\" + Name + ".value.txt"))
     {
         var sum = num.Domain.Arguments.Select(z => z * num[z]).Sum();
         var wei = num.Domain.Arguments.Select(z => num[z]).Sum();
         file.WriteLine("{0:0.000}", Math.Round(sum / wei, 3));
     }
 }