public FuzzyInputData() { values = new FuzzyNumber[NumberOfVariables]; for (int i = 0; i < values.Length; i++) { values[i] = new FuzzyNumber(); } }
public static FuzzyNumber operator &(FuzzyNumber a, FuzzyNumber b) { var and = new FuzzyNumber(); foreach (FuzzyUtility.FuzzyStates state in System.Enum.GetValues(typeof(FuzzyUtility.FuzzyStates))) { and[state] = Mathf.Min(a[state], b[state]); } return(and); }
public static FuzzyNumber operator |(FuzzyNumber a, FuzzyNumber b) { var or = new FuzzyNumber(); foreach (FuzzyUtility.FuzzyStates state in System.Enum.GetValues(typeof(FuzzyUtility.FuzzyStates))) { or[state] = Mathf.Max(a[state], b[state]); } return(or); }
public static FuzzyNumber operator !(FuzzyNumber n) { var negation = new FuzzyNumber(); foreach (FuzzyUtility.FuzzyStates state in System.Enum.GetValues(typeof(FuzzyUtility.FuzzyStates))) { negation[state] = 1f - n[state]; } return(negation); }
private float GetCrispValue(FuzzyNumber fuzzyNumber) { switch (defuzificationMethod) { case FuzzySystem.DefuzzificationMethod.Maximum: return(Maximum(fuzzyNumber)); case FuzzySystem.DefuzzificationMethod.CenterOfMass: return(CenterOfMass(fuzzyNumber)); default: return(-1); } }
private float CenterOfMass(FuzzyNumber fuzzyNumber) { float weightedTotal = 0; float sum = fuzzyNumber.Sum; // weight each value foreach (FuzzyUtility.FuzzyStates state in System.Enum.GetValues(typeof(FuzzyUtility.FuzzyStates))) { float weighedValue = fuzzyNumber[state] * FuzzyNumber.NormalisedStateValues[state]; weighedValue /= sum; weightedTotal += weighedValue; } return(weightedTotal); }
private float Maximum(FuzzyNumber fuzzyNumber) { float max = 0; FuzzyUtility.FuzzyStates maxState = FuzzyUtility.FuzzyStates.Z; foreach (FuzzyUtility.FuzzyStates state in System.Enum.GetValues(typeof(FuzzyUtility.FuzzyStates))) { float current = fuzzyNumber[state]; if (current <= max) { continue; } else { maxState = state; max = current; } } float meanOfMaximum = FuzzyNumber.NormalisedStateValues[maxState]; return(meanOfMaximum); }