示例#1
0
        public FuzzyLinguisticVariable CreateFLV(string variableName)
        {
            FuzzyLinguisticVariable variableToReturn = new FuzzyLinguisticVariable();

            fuzzyVariables.Add(variableName, variableToReturn);
            return(variableToReturn);
        }
示例#2
0
        // Always uses MaxAv.
        public double DeFuzzify(string keyOfFLV)
        {
            RunRules();
            FuzzyLinguisticVariable consequentToDefuzzify = fuzzyVariables[keyOfFLV];
            // calculation is (sum of: (representative value * confidence) / (sum of confidence)
            double sumRepValueConfidence = 0;
            double sumOfConfidence       = 0;

            foreach (FuzzyRule rule in fuzzyRules)
            {
                // calculate sum of: (representative value * confidence)
                sumRepValueConfidence += rule.FuzzyRealRule.DegreeOfMembership * rule.Consequent.MidPointMembershipValue;
                // calculation of: (sum of confidence)
                sumOfConfidence += rule.FuzzyRealRule.DegreeOfMembership;
            }

            // calculate defuzzified crisp value
            double defuzzifiedValue = sumRepValueConfidence / sumOfConfidence;

            return(defuzzifiedValue);
        }