/// <summary> /// Important! Get set of fuzzy from library /// </summary> /// <param name="one"></param> /// <param name="two"></param> /// <param name="rel"></param> /// <returns></returns> private static double CompareDisFS(object one, object two, string rel) { DiscreteFuzzySetBLL disfs1 = DiscreteFuzzySetBLL.GetByName(one.ToString().Trim()); DiscreteFuzzySetBLL disfs2 = new DiscreteFuzzySetBLL(two.ToString().Trim()); if (disfs2.CheckDiscFuzzySetByName(two.ToString().Trim())) { disfs2 = DiscreteFuzzySetBLL.GetByName(two.ToString().Trim()); } else { if (!new FProDataTypeBLL().IsDataType(two.ToString().Trim(), "Double")) { disfs2.FuzzySetName = two.ToString().Trim(); disfs2.ValueSet.Add(0); disfs2.MembershipSet.Add(0); } else { disfs2.FuzzySetName = two.ToString().Trim(); disfs2.ValueSet.Add(Double.Parse(two.ToString())); disfs2.MembershipSet.Add(1); } } if (disfs1 == null || disfs2 == null) { return(-1.0); } else { FuzzyInterpreter fuzzinter = new FuzzyInterpreter(); double pro = fuzzinter.interpreteForDiscFS(disfs1, disfs2, rel); return(pro); } }
private static bool EqualDisFS(object one, object two) { if (one.ToString().Trim() == two.ToString().Trim()) { return(true); } else { DiscreteFuzzySetBLL disfs1 = DiscreteFuzzySetBLL.GetByName(one.ToString().Trim()); DiscreteFuzzySetBLL disfs2 = DiscreteFuzzySetBLL.GetByName(two.ToString().Trim()); if (disfs1 == null || disfs2 == null) { return(false); } else { List <Double> h1 = disfs1.getXsForMembership(0.1); List <Double> h2 = disfs2.getXsForMembership(0.1); for (int i = 0; i < h1.Count; i++) { for (int j = 0; j < h2.Count; j++) { if (h1[i] == h2[j]) { return(true); } } } return(false); } } }
private DiscreteFuzzySetBLL discretize(ContinuousFuzzySetBLL contFS, double beginPoint, double epsilon) { DiscreteFuzzySetBLL discFS = new DiscreteFuzzySetBLL(); discFS.FuzzySetName = contFS.FuzzySetName; for (double val = beginPoint; val <= contFS.BottomRight; val += epsilon) { double mbs = contFS.GetMembershipAt(val); discFS.AddPoint(val, mbs); } return(discFS); }
public double interpreteForContFS(ContinuousFuzzySetBLL contFS1, ContinuousFuzzySetBLL contFS2, string rel) { int everageNumPoint = 20; //double epsilon = 0.1; double beginPoint1 = contFS1.BottomLeft; double beginPoint2 = contFS2.BottomLeft; double epsilon = (beginPoint1 + beginPoint2) / everageNumPoint; DiscreteFuzzySetBLL discFS1 = discretize(contFS1, beginPoint1, epsilon); DiscreteFuzzySetBLL discFS2 = discretize(contFS2, beginPoint2, epsilon); return(interpreteForDiscFS(discFS1, discFS2, rel)); }
/// <summary> /// Important! Calculate m (mass assignment) (phep gan khoi), calculate prob (A->B) /// </summary> /// <param name="discFS1">A</param> /// <param name="discFS2">B</param> /// <param name="rel"></param> /// <returns></returns> public double interpreteForDiscFS(DiscreteFuzzySetBLL discFS1, DiscreteFuzzySetBLL discFS2, string rel) { double result = 0; //calculate m (Phep gan khoi). MassAssignmentBLL mass1 = new MassAssignmentBLL(discFS1); MassAssignmentBLL mass2 = new MassAssignmentBLL(discFS2); for (int i = 0; i < mass1.ProSubset.Count; i++) { for (int j = 0; j < mass2.ProSubset.Count; j++) { double add = (relProbOnSets(mass1.ProSubset[i].Subset, mass2.ProSubset[j].Subset, rel)) * (mass1.ProSubset[i].MassSubset) * (mass2.ProSubset[j].MassSubset); result = result + add; } } return(Math.Round(result, 4)); }
public DiscreteFuzzySetBLL(DiscreteFuzzySetBLL disFuzzy) : base(disFuzzy) { this.valueSet = disFuzzy.valueSet; this.membershipSet = disFuzzy.membershipSet; }
public MassAssignmentBLL() { this.disFuzzy = new DiscreteFuzzySetBLL(); this.proSubset = new List <ProbSubSetBLL>(); }
public MassAssignmentBLL(MassAssignmentBLL massAssign) { this.disFuzzy = massAssign.disFuzzy; this.proSubset = massAssign.proSubset; }
public MassAssignmentBLL(DiscreteFuzzySetBLL dis, List <ProbSubSetBLL> pro) { this.disFuzzy = dis; this.proSubset = pro; }
public MassAssignmentBLL(DiscreteFuzzySetBLL dis) { this.disFuzzy = dis; this.proSubset = new List <ProbSubSetBLL>(); setMassAssignment(); }