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)); }
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)); }
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 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 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 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); }