internal FuzzySet moRhs; // Righthand side value #endregion Fields #region Constructors /// <summary> Creates a new fuzzy clause with the specified lvalue, operator, and /// rvalue. /// /// </summary> /// <param name="lhs">the FuzzyRuleVariable which is the lvalue /// </param> /// <param name="op">the integer operator /// </param> /// <param name="rhs">the FuzzySet which is the rvalue /// </param> protected internal FuzzyClause(FuzzyRuleVariable lhs, EnumFuzzyOperator op, FuzzySet rhs) { this.moLhs = lhs; this.meOp = op; this.moRhs = rhs; mbConsequent = (op == EnumFuzzyOperator.Assign); }
/// <summary> /// Asserts the truth values from the given fuzzy set. /// </summary> /// <param name="inputSet">the FuzzySet object to be used for the assertion</param> internal virtual void Assert(FuzzySet inputSet) { for (int i = 0; i < Constants.FUZZY_MAXVALUES; ++i) { if (mdTruthVector[i] > inputSet.GetTruthValue(i)) { mdTruthVector[i] = inputSet.GetTruthValue(i); } } }
/// <summary> /// Copies the truth values from the given fuzzy set. /// </summary> /// <param name="inputSet">the FuzzySet object to be copied</param> internal virtual void Copy(FuzzySet inputSet) { for (int i = 0; i < Constants.FUZZY_MAXVALUES; ++i) { mdTruthVector[i] = inputSet.GetTruthValue(i); } mbSetEmpty = false; }
/// <summary> /// Correlates the working set with the given input set using the given /// correlation method and truth value. /// </summary> /// <param name="inputSet">the FuzzySet object that contains the fuzzy set to be /// correlated with</param> /// <param name="corrMethod">the integer that represents the correlation method</param> /// <param name="truthValue">the double truth value</param> internal virtual void CorrelateWith(FuzzySet inputSet, EnumFuzzyCorrelationMethod corrMethod, double truthValue) { switch (corrMethod) { case EnumFuzzyCorrelationMethod.Minimise: for (int i = 0; i < Constants.FUZZY_MAXVALUES; ++i) { if (truthValue <= inputSet.GetTruthValue(i)) { mdTruthVector[i] = truthValue; } else { mdTruthVector[i] = inputSet.GetTruthValue(i); } } break; case EnumFuzzyCorrelationMethod.Product: for (int i = 0; i < Constants.FUZZY_MAXVALUES; ++i) { mdTruthVector[i] = (inputSet.GetTruthValue(i) * truthValue); } break; } }
/// <summary> /// Copies the input set if the current working set is empty, otherwise /// asserts the given set. /// </summary> /// <param name="inputSet">the FuzzySet object to be copied or asserted</param> internal virtual void CopyOrAssertFuzzy(FuzzySet inputSet) { if (mbSetEmpty) { Copy(inputSet); } else { Assert(inputSet); } }
/// <summary> /// Set the Raw Value /// </summary> /// <param name="newSet"></param> internal virtual void SetRawValue(FuzzySet newSet) { //This is an assertion following the "Minimum Law of Fuzzy Assertions". //Change the Fuzzy Work Space 'valFzy' with the new set. moValFzy.CopyOrAssertFuzzy(newSet); //When all done, defuzzify the work space and store in valCrisp mdValCrisp = moValFzy.Defuzzify(moRuleBase.DefuzzifyMethod); }
/// <summary> /// Set the Truth Value /// </summary> /// <param name="newSet"></param> /// <param name="truthValue"></param> internal virtual void SetFuzzyValue(FuzzySet newSet, double truthValue) { //This is correlation with a truth value. //Change the Fuzzy Work Space 'valFzy' with the new set //correlated to truth value 'truthValue' moValFzyTmp.CorrelateWith(newSet, moRuleBase.CorrelationMethod, truthValue); moValFzy.ImplicateTo(moValFzyTmp, moRuleBase.InferenceMethod); //When all done, defuzzify the work space and store in valCrisp mdValCrisp = moValFzy.Defuzzify(moRuleBase.DefuzzifyMethod); }
/// <summary> /// Set the Fuzzy Value /// </summary> /// <param name="newValue"></param> public override void SetFuzzyValue(FuzzySet newValue) { SetRawValue(newValue); }
/// <summary> /// Determines the Membership /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> /// <returns></returns> internal static double Compare(FuzzyRuleVariable lhs, FuzzySet rhs) { // Take crisp value and look up membership return (rhs.Membership(lhs.GetNumericValue())); }
/// <summary> /// Assign the Rhs Fuzzy to the Lhs with a truth value /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> /// <param name="truthValue"></param> internal static void Assign(FuzzyRuleVariable lhs, FuzzySet rhs, double truthValue) { //This is correlation with a truth value. ((ContinuousFuzzyRuleVariable)lhs).SetFuzzyValue(rhs, truthValue); }
/// <summary> /// Assign the Rhs to the Lhs /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> internal static void Assign(FuzzyRuleVariable lhs, FuzzySet rhs) { lhs.SetFuzzyValue(rhs); }