public void Set <T>(FuzzyValue <T> fuzzyValue) where T : struct, System.IConvertible { FuzzyUtils.IsGenericParameterValid <T>(); EnumKey key = EnumKey.From(fuzzyValue.linguisticVariable); float degree = fuzzyValue.membershipDegree; this._internalDictionary[key] = degree; }
public void Set(FuzzyVariable <T> fuzzyVariable) { if (fuzzyVariable == null) { return; } int idx = Array.IndexOf <EnumKey <T> >(this.enumValues, EnumKey <T> .From(fuzzyVariable.LinguisticVariable)); this._variables[idx] = fuzzyVariable; }
private void ClearOutputs() { List <FuzzyValue <T> > duplicateList = null; for (int i = 0; i < this.outputEnumValues.Length; i++) { duplicateList = this.duplicateOutputs[EnumKey.From(this.outputEnumValues[i])]; duplicateList.Clear(); } }
private void Initialize() { FuzzyUtils.IsGenericParameterValid <T>(); this.duplicateOutputs = new Dictionary <EnumKey, List <FuzzyValue <T> > >(); this.outputEnumValues = FuzzyUtils.GetEnumValues <T>(); for (int i = 0; i < this.outputEnumValues.Length; i++) { this.duplicateOutputs.Add(EnumKey.From(this.outputEnumValues[i]), new List <FuzzyValue <T> >(10)); } }
public FuzzyValue <T> Get <T>(T linguisticVariable) where T : struct, System.IConvertible { FuzzyUtils.IsGenericParameterValid <T>(); EnumKey key = EnumKey.From(linguisticVariable); float degree = 0.0f; this._internalDictionary.TryGetValue(key, out degree); FuzzyValue <T> fuzzyValue = new FuzzyValue <T>(linguisticVariable, degree); return(fuzzyValue); }
public FuzzySet() { FuzzyUtils.IsGenericParameterValid <T>(); var enumArr = FuzzyUtils.GetEnumValues <T>(); this.enumValues = new EnumKey <T> [enumArr.Length]; for (int i = 0; i < this.enumValues.Length; i++) { this.enumValues[i] = EnumKey <T> .From(enumArr[i]); } this._variables = new FuzzyVariable <T> [this.enumValues.Length]; }
private void CollapseOutputs(FuzzyValue <T>[] values) { List <FuzzyValue <T> > duplicateList = null; for (int i = 0; i < values.Length; i++) { var outputValue = values[i]; if (outputValue.membershipDegree <= 0.0f) { continue; } duplicateList = this.duplicateOutputs[EnumKey.From(outputValue.linguisticVariable)]; duplicateList.Add(outputValue); } }
public void MergeValues(FuzzyValue <T>[] values, FuzzyValueSet mergedOutputs) { this.CollapseOutputs(values); float maxValue = 0.0f; FuzzyValue <T> value; List <FuzzyValue <T> > duplicateList = null; for (int i = 0; i < this.outputEnumValues.Length; i++) { maxValue = 0.0f; duplicateList = this.duplicateOutputs[EnumKey.From(this.outputEnumValues[i])]; for (int j = 0; j < duplicateList.Count; j++) { value = duplicateList[j]; if (value.membershipDegree > maxValue) //Or-ing outputs { maxValue = value.membershipDegree; } } mergedOutputs.Set(new FuzzyValue <T>(this.outputEnumValues[i], maxValue)); duplicateList.Clear(); } }
public FuzzyVariable <T> Get(T linguisticVar) { int idx = Array.IndexOf <EnumKey <T> >(this.enumValues, EnumKey <T> .From(linguisticVar)); return(this._variables[idx]); }