/// <summary> /// Takes <see cref="FuzzyLogic.FuzzyOutputData"/> and from a call of <see cref="FuzzyLogic.InferenceEngine.ApplyRulset(FuzzyInputData)"/> /// and returns a new into <see cref="FuzzyLogic.CrispOutput"/> using the current method of <see cref="FuzzyLogic.Defuzzifier.defuzificationMethod"/> /// </summary> /// <param name="fuzzyOutput">The fuzzy data to be defuzzified</param> /// <returns>A <see cref="FuzzyLogic.CrispOutput"/> which can be used by the external system</returns> public CrispOutput Defuzzify(FuzzyOutputData fuzzyOutput) { CrispOutput crispOutput = new CrispOutput(); foreach (CrispOutput.Outputs variable in CrispOutput.OutputEnumvalues) { crispOutput[variable] = GetCrispValue(fuzzyOutput[variable]); } return(crispOutput); }
/// <summary> /// Applies the rulset in <see cref="FuzzyLogic.InferenceEngine.fuzzyRules"/> to <paramref name="fuzzyInput"/> and produces a new <see cref="FuzzyLogic.FuzzyOutputData"/> based on these rules /// </summary> /// <param name="fuzzyInput">The fussified input given by <see cref="FuzzyLogic.Fuzzifier.Fuzzify(CrispInput)"/> on which the rules will be applied</param> /// <returns>A new <see cref="FuzzyLogic.FuzzyOutputData"/> based on these rules</returns> public FuzzyOutputData ApplyRulset(FuzzyInputData fuzzyInput) { List <FuzzyOutputData> unaggragatedFuzzyOuputs = new List <FuzzyOutputData>(); ApplySimpleRules(fuzzyInput, unaggragatedFuzzyOuputs); ApplyLogicalRules(fuzzyInput, unaggragatedFuzzyOuputs); FuzzyOutputData outputData = AgragateFuzzyOutputs(unaggragatedFuzzyOuputs); return(outputData); }
/// <summary> /// Agragates a list of <see cref="FuzzyLogic.FuzzyOutputData"/> by taking the maximum value of each <see cref="FuzzyLogic.FuzzyNumber.FuzzyStates"/> for each <see cref="FuzzyLogic.CrispOutput.Outputs"/> /// </summary> /// <returns>A single <see cref="FuzzyLogic.FuzzyOutputData"/></returns> private FuzzyOutputData AgragateFuzzyOutputs(List <FuzzyOutputData> unaggragatedFuzzyOuputs) { FuzzyOutputData outputData = new FuzzyOutputData(); foreach (CrispOutput.Outputs outputVariable in CrispOutput.OutputEnumvalues) { foreach (FuzzyUtility.FuzzyStates membershipState in System.Enum.GetValues(typeof(FuzzyUtility.FuzzyStates))) { outputData[outputVariable][membershipState] = GetMaxVariableMembershipState(outputVariable, membershipState, unaggragatedFuzzyOuputs); } } return(outputData); }
private void ApplySimpleRules(FuzzyInputData fuzzyInput, List <FuzzyOutputData> unaggragatedFuzzyOuputs) { foreach (FuzzyRulesList.SimpleFuzzyRule rule in fuzzyRules.simpleRules) { FuzzyOutputData fuzzyOutput = new FuzzyOutputData(); float value = GetValueOfAnticedent(fuzzyInput, rule.anticedent); fuzzyOutput[rule.consequent.output][rule.consequent.state] = value; unaggragatedFuzzyOuputs.Add(fuzzyOutput); } }
private void ApplyLogicalRules(FuzzyInputData fuzzyInput, List <FuzzyOutputData> unaggragatedFuzzyOuputs) { foreach (FuzzyRulesList.LogicalFuzzyRule rule in fuzzyRules.logicRules) { FuzzyOutputData fuzzyOutput = new FuzzyOutputData(); float anticedent1 = GetValueOfAnticedent(fuzzyInput, rule.anticedent1); float anticedent2 = GetValueOfAnticedent(fuzzyInput, rule.anticedent2); float value = ApplyLogicalRelationshipToAnticedent1Values(anticedent1, anticedent2, rule.logicalRelationship); fuzzyOutput[rule.consequent.output][rule.consequent.state] = value; unaggragatedFuzzyOuputs.Add(fuzzyOutput); } }
private void ApplyLogicalRules(FuzzyInputData fuzzyInput, List <FuzzyOutputData> unaggragatedFuzzyOuputs) { foreach (LogicalFuzzyRule rule in fuzzyRules.logicRules) { FuzzyOutputData fuzzyOutput = new FuzzyOutputData(); float predicate1 = GetValueOfPredicate(fuzzyInput, rule.predicate1); float predicate2 = GetValueOfPredicate(fuzzyInput, rule.predicate2); float value = ApplyLogicalRelationshipToPredicateValues(predicate1, predicate2, rule.logicalRelationship); fuzzyOutput[rule.consequent.output][rule.consequent.state] = value; unaggragatedFuzzyOuputs.Add(fuzzyOutput); } }