예제 #1
0
        public static void WriteToStream(StreamWriter stream)
        {
            stream.WriteLine("A\n" + A);
            stream.WriteLine("B\n" + B);
            stream.WriteLine("C\n" + C);

            var lst = new List<double>();
            for (var i = 0; i < A.Set.Length; i++)
            {
                var value = A[i]*_lambdaA + B[i]*_lambdaB + C[i]*_lambdaC;
                lst.Add(value < 1 ? value : 1);
            }
            var newFuzzy = new FuzzySet(lst);
            stream.WriteLine("new Fuzzy\n" + newFuzzy);

            var fuzzySumWithAlpha = A.StrongUnion(B).StrongUnion(C).GetAlphaCut(0.4);
            var fuzzyMultWithAlpha = A.StrongIntersection(B).StrongIntersection(C).GetAlphaCut(0.4);
            var fuzzyAlphaUnion = A.GetAlphaCut(0.4) | B.GetAlphaCut(0.4) | C.GetAlphaCut(0.4);
            var fuzzyAlphaIntersection = A.GetAlphaCut(0.4) & B.GetAlphaCut(0.4) & C.GetAlphaCut(0.4);
            stream.WriteLine();
            stream.WriteLine("A Strong Union B Strong Union C\n" + fuzzySumWithAlpha);
            stream.WriteLine("A U B U C\n" + fuzzyAlphaUnion);
            stream.WriteLine("Include: " + fuzzyAlphaUnion.In(fuzzySumWithAlpha));
            stream.WriteLine("(A Strong Intersection B Strong Intersection C)a\n" + fuzzyMultWithAlpha);
            stream.WriteLine("Aa∩Ba∩Ca\n" + fuzzyAlphaIntersection);
            stream.WriteLine("Include: " + fuzzyMultWithAlpha.In(fuzzyAlphaIntersection));
        }
예제 #2
0
 public FuzzySet StrongUnion(FuzzySet other)
 {
     return new FuzzySet(Set.Select((val, i) => ((other[i] + val) < 1) ? other[i] + val : 1));
 }
예제 #3
0
 public FuzzySet StrongIntersection(FuzzySet other)
 {
     return new FuzzySet(Set.Select((v, i) => other.Set[i]*v));
 }
예제 #4
0
 public bool In(FuzzySet other)
 {
     return Set.Select((val, i) => other[i] < val).Any();
 }
예제 #5
0
 protected bool Equals(FuzzySet other)
 {
     return this == other;
 }