private int varId; // Unique Id of next variable #endregion Fields #region Constructors /// <summary> /// Creaes a Fuzzy Rule Base /// </summary> /// <param name="vsName">Name of the Rule Base</param> public FuzzyRuleBase(string vsName) { mdAlphaCut = Constants.FuzzyAlphaCutDefault; meCorrelationMethod = EnumFuzzyCorrelationMethod.Product; meDefuzzifyMethod = EnumFuzzyDefuzzifyMethod.Centroid; meInferenceMethod = EnumFuzzyInferenceMethod.Add; varId = Constants.FuzzyVarIdInitial; moVariableList = new Dictionary<string, FuzzyRuleVariable>(); ruleId = Constants.FuzzyRuleIdInitial; moRuleList = new List<FuzzyRule>(10); moCndRuleList = new List<FuzzyRule>(10); moUncRuleList = new List<FuzzyRule>(10); moFbInitial = new System.Collections.BitArray(Constants.FUZZY_MAXVALUES); msName = vsName; }
/// <summary> /// Clear the RuleBase /// </summary> public void Clear() { // Ruleset name msName = ""; // Ruleset options mdAlphaCut = Constants.FuzzyAlphaCutDefault; meCorrelationMethod = EnumFuzzyCorrelationMethod.Product; meDefuzzifyMethod = EnumFuzzyDefuzzifyMethod.Centroid; meInferenceMethod = EnumFuzzyInferenceMethod.Add; // Lists of variables varId = Constants.FuzzyVarIdInitial; moVariableList.Clear(); // Lists of rules ruleId = Constants.FuzzyRuleIdInitial; moRuleList.Clear(); moCndRuleList.Clear(); moUncRuleList.Clear(); List<FuzzyRule> temp_fuzzylist; // Fact Base moFbInitial = new System.Collections.BitArray(Constants.FUZZY_MAXVALUES); }
/// <summary> /// Implicates the current working set to the given fuzzy set using the /// given infer method. /// </summary> /// <param name="inputSet">the WorkingFuzzySet object to implicate to</param> /// <param name="inferMethod">the integer that represents the infer method</param> internal virtual void ImplicateTo(WorkingFuzzySet inputSet, EnumFuzzyInferenceMethod inferMethod) { switch (inferMethod) { case EnumFuzzyInferenceMethod.Add: for (int i = 0; i < Constants.FUZZY_MAXVALUES; ++i) { double sum = mdTruthVector[i] + inputSet.GetTruthValue(i); if (sum < 1.0) { mdTruthVector[i] = sum; } else { mdTruthVector[i] = 1.0; } } break; case EnumFuzzyInferenceMethod.MinMax: for (int i = 0; i < Constants.FUZZY_MAXVALUES; ++i) { if (mdTruthVector[i] < inputSet.GetTruthValue(i)) { mdTruthVector[i] = inputSet.GetTruthValue(i); } } break; } }