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));
 }
Ejemplo n.º 2
0
        public IFuzzySet Calculate(IFuzzySet set)
        {
            IList <double> memberships = new List <double>();

            for (int i = 0; i < set.GetDomain().GetCardinality(); i++)
            {
                double value = set.GetMembershipFor(set.GetDomain().ElementAt(i));
                memberships.Add(1 - value);
            }
            return(FuzzySetFactory.CreateFuzzySet(set.GetDomain(), memberships));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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));
        }