// Given a fuzzy variable and a defuzzification method this returns a crisp value public double DeFuzzify(string key, DefuzzifyMethod method) { if (!_variables.ContainsKey(key)) { throw new Exception("FuzzyModule: DeFuzzify: Key not found."); } // Clear the DOMs _SetConfidencesOfConsequentsToZero(); // Process foreach (var rule in _rules) { rule.Calculate(); } // Defuzzify using specific method switch (method) { case DefuzzifyMethod.centroid: return(_variables[key].DeFuzzifyCentroid(NUM_SAMPLES)); case DefuzzifyMethod.max_av: return(_variables[key].DeFuzzifyMaxAv()); } return(0); }
public double Defuzzify(string name, DefuzzifyMethod method) { // Make sure the FLV exists in this module if (!Variables.ContainsKey(name)) { throw new KeyNotFoundException(); } // Clear all consequent DOMs SetConfidencesOfConsequentsToZero(); // Process the rules foreach (FuzzyRule rule in Rules) { rule.Calculate(); } // Defuzzify the resultant conclusion using the specified method switch (method) { case DefuzzifyMethod.Centroid: int NumSamples = 15; return(Variables[name].DefuzzifyCentroid(NumSamples)); case DefuzzifyMethod.MaxAV: return(Variables[name].DefuzzifyMaxAv()); } return(0); }
public double DeFuzzify(string NameOfFLV, DefuzzifyMethod method) { if (m_Variables.ContainsKey(NameOfFLV)) { SetConfidencesOfConsequentsToZero(); foreach (FuzzyRule fr in m_Rules) { fr.Calculate(); } switch (method) { case DefuzzifyMethod.centroid: FuzzyVariable fv; m_Variables.TryGetValue(NameOfFLV, out fv); return(fv.DefuzzifyCentroid(NumSamples)); case DefuzzifyMethod.max_av: FuzzyVariable f; m_Variables.TryGetValue(NameOfFLV, out f); return(f.DeFuzzifyMaxAv()); } return(0.0f); } return(0.0f); }
//---------------------------- DeFuzzify -------------------------------------- // // given a fuzzy variable and a deffuzification method this returns a // crisp value //----------------------------------------------------------------------------- public float DeFuzzify(string NameOfFLV, DefuzzifyMethod method) { //clear the DOMs of all the consequents of all the rules SetConfidencesOfConsequentsToZero(); foreach (var curRule in m_Rules) { curRule.Calculate(); } //now defuzzify the resultant conclusion using the specified method switch (method) { case DefuzzifyMethod.centroid: return((float)m_Variables[NameOfFLV].DeFuzzifyCentroid((int)NumSamples.NumSamples)); break; case DefuzzifyMethod.max_av: return((float)m_Variables[NameOfFLV].DeFuzzifyMaxAv()); break; } return(0); }
public double DeFuzzify(string name, DefuzzifyMethod method) { if (m_Variables.ContainsKey(name)) { SetConfidencesOfConsequentsToZero(); foreach (FuzzyRule fuzzyRule in m_Rules) { fuzzyRule.Calculate(); } switch (method) { case DefuzzifyMethod.Centroid: FuzzyVariable fuzzyVariable; m_Variables.TryGetValue(name, out fuzzyVariable); return(fuzzyVariable.DefuzzifyCentroid(NumSamples)); case DefuzzifyMethod.MaxAV: FuzzyVariable fuzzyVariableMaxAv; m_Variables.TryGetValue(name, out fuzzyVariableMaxAv); return(fuzzyVariableMaxAv.DeFuzzifyMaxAv()); } return(0.0f); } return(0.0f); }
public double DeFuzzify(string FLVName, DefuzzifyMethod method) { if (_memberVarMap.ContainsKey(FLVName)) { SetConfidencesOfConsequentsToZero(); foreach (FuzzyRule rule in _memberRules) { rule.Calculate(); } switch (method) { case DefuzzifyMethod.MAX_AV: return(_memberVarMap[FLVName].DefuzzifyMaxAv()); case DefuzzifyMethod.CENTROID: return(_memberVarMap[FLVName].DefuzzifyCentroid(NUMSAMPLES)); } } return(0); }
/// <summary> /// Given a fuzzy variable and a defuzzification method this returns a crisp value. /// </summary> /// <param name="nameOfFlv">Name of the fuzzy linguistic variable.</param> /// <param name="method">The defuzzification method.</param> /// <returns>A crisp value.</returns> public float DeFuzzify(string nameOfFlv, DefuzzifyMethod method) { // first make sure the key exists if (!Variables.ContainsKey(nameOfFlv)) { throw new Exception("FuzzyModule.DeFuzzify: key not found."); } // clear the DOMs of all the consequents of all the rules SetConfidencesOfConsequentToZero(); // process the rules foreach (var rule in Rules) { rule.Calculate(); } // now defuzzify the resultant conclusion using the specified method return(method switch { DefuzzifyMethod.Centroid => Variables[nameOfFlv].DeFuzzifyCentroid(_CROSS_SECTION_SAMPLE_COUNT), DefuzzifyMethod.MaxAv => Variables[nameOfFlv].DeFuzzifyMaxAv(), _ => 0 });
///<summary> ///given a fuzzy variable and a defuzzification method this returns a ///crisp value ///</summary> ///<param name="nameOfFLV"></param> ///<param name="method"></param> ///<returns></returns> public float DeFuzzify(string nameOfFLV, DefuzzifyMethod method) { //first make sure the key exists Assert.Fatal(Variables.ContainsKey(nameOfFLV), "FuzzyModule.DeFuzzify: key not found"); //clear the DOMs of all the consequents of all the rules SetConfidencesOfConsequentsToZero(); //process the rules foreach (FuzzyRule curRule in Rules) { curRule.Calculate(); } //now defuzzify the resultant conclusion using the specified method switch (method) { case DefuzzifyMethod.Centroid: return Variables[nameOfFLV].DeFuzzifyCentroid( (int) CrossSections.NumSamples); case DefuzzifyMethod.MaxAv: return Variables[nameOfFLV].DeFuzzifyMaxAv(); } return 0; }