public static IFuzzySet Lambda(IDomain domain, params double[] points)
 {
     double[] memberships = new double[domain.GetCardinality()];
     for (int index = 0; index < domain.GetCardinality(); index++)
     {
         double value = (double)domain.ElementAt(index)[0];
         if (value <= points[0])
         {
             memberships[index] = 0;
         }
         else if (value >= points[2])
         {
             memberships[index] = 0;
         }
         else if (value > points[0] && value < points[1])
         {
             memberships[index] = (value - points[0]) / (points[1] - points[0]);
         }
         else
         {
             memberships[index] = (points[2] - value) / (points[2] - points[1]);
         }
     }
     return(FuzzySetFactory.CreateFuzzySet(domain, memberships));
 }
示例#2
0
        public IFuzzySet Fuzzyfie(string[] value, IDomain domain)
        {
            IList <double> memberships = new List <double>(new double[domain.GetCardinality()]);

            memberships[domain.GetIndexOfElement(domain.FromStringRepresentation(value))] = 1;
            return(FuzzySetFactory.CreateFuzzySet(domain, memberships));
        }
示例#3
0
 public FuzzySet(IDomain domain, IDictionary <string[], double> memberships)
 {
     this.domain      = domain;
     this.memberships = new List <double>(new double[domain.GetCardinality()]);
     foreach (var membership in memberships)
     {
         this.memberships[domain.GetIndexOfElement(domain.FromStringRepresentation(membership.Key))] = membership.Value;
     }
 }
 public FuzzySet(IDomain domain, IDictionary<string[], double> memberships)
 {
     this.domain = domain;
     this.memberships = new List<double>(new double[domain.GetCardinality()]);
     foreach (var membership in memberships)
     {
         this.memberships[domain.GetIndexOfElement(domain.FromStringRepresentation(membership.Key))] = membership.Value;
     }
 }
 public static IFuzzySet L(IDomain domain, params int[] points)
 {
     double[] memberships = new double[domain.GetCardinality()];
     for (int index = 0; index < domain.GetCardinality(); index++)
     {
         int value = (int)domain.ElementAt(index)[0];
         if (value <= points[0])
         {
             memberships[index] = 1;
         }
         else if (value >= points[1])
         {
             memberships[index] = 0;
         }
         else
         {
             memberships[index] = (double)(points[1] - value) / (points[1] - points[0]);
         }
     }
     return FuzzySetFactory.CreateFuzzySet(domain, memberships);
 }
 public IFuzzySet CylindricalExtension(IDomain domain)
 {
     int other = this.domain.GetDomainComponents().Contains(domain.GetDomainComponents()[0]) ? domain.GetDomainComponents().Count() - 1 : 0;
     IList<double> memberships = new List<double>();
     for (int i = 0; i < domain.GetCardinality(); i++)
     {
         IList<object> element = domain.ElementAt(i).ToList();
         element.RemoveAt(other);
         memberships.Add(this.GetMembershipFor(element.ToArray()));
     }
     return new FuzzySet(domain, memberships);
 }
示例#7
0
        public IFuzzySet CylindricalExtension(IDomain domain)
        {
            int            other       = this.domain.GetDomainComponents().Contains(domain.GetDomainComponents()[0]) ? domain.GetDomainComponents().Count() - 1 : 0;
            IList <double> memberships = new List <double>();

            for (int i = 0; i < domain.GetCardinality(); i++)
            {
                IList <object> element = domain.ElementAt(i).ToList();
                element.RemoveAt(other);
                memberships.Add(this.GetMembershipFor(element.ToArray()));
            }
            return(new FuzzySet(domain, memberships));
        }
 public static void Print(IDomain domain, string headingText)    //metoda za ispis elemenata domene
 {
     if (headingText != null)
     {
         Console.WriteLine(headingText);
     }
     foreach (DomainElement e in domain)
     {
         Console.WriteLine("Element domene: " + e);
     }
     Console.WriteLine("Kardinalitet domene je: " + domain.GetCardinality());
     Console.WriteLine();
 }
示例#9
0
        private static void PrintDomain(IDomain domain, string headingText = "")
        {
            if (!string.IsNullOrEmpty(headingText))
            {
                Console.WriteLine(headingText);
            }

            foreach (DomainElement de in domain)
            {
                Console.WriteLine($"Element of domain: ({de})");
            }

            Console.WriteLine($"Domain cardinality is: {domain.GetCardinality()}");
            Console.WriteLine();
        }
示例#10
0
        public IFuzzySet Calculate(IFuzzySet first, IFuzzySet second)
        {
            IList <double> memberships = new List <double>();
            IDomain        domain      = DomainFactory.CreateDomain(new IDomain[] { first.GetDomain(), second.GetDomain() });
            IFuzzySet      firstCyl    = first.CylindricalExtension(domain);
            IFuzzySet      secondCyl   = second.CylindricalExtension(domain);

            for (int i = 0; i < domain.GetCardinality(); i++)
            {
                double value1 = firstCyl.GetMembershipFor(domain.ElementAt(i));
                double value2 = secondCyl.GetMembershipFor(domain.ElementAt(i));
                memberships.Add(value1 * value2);
            }
            return(FuzzySetFactory.CreateFuzzySet(domain, memberships));
        }
示例#11
0
        public IFuzzySet Calculate(IFuzzySet first, IFuzzySet second)
        {
            if (!first.GetDomain().Equals(second.GetDomain()))
            {
                throw new ApplicationException("Domains are not the same.");
            }
            IList <double> memberships = new List <double>();
            IDomain        domain      = first.GetDomain();

            for (int i = 0; i < domain.GetCardinality(); i++)
            {
                double value1 = first.GetMembershipFor(domain.ElementAt(i));
                double value2 = second.GetMembershipFor(domain.ElementAt(i));
                memberships.Add(value1 + value2 - value1 * value2);
            }
            return(FuzzySetFactory.CreateFuzzySet(domain, memberships));
        }
 public MutableFuzzySet(IDomain domain)
 {
     _domain      = domain;
     _memberships = new double[domain.GetCardinality()];
 }