Exemple #1
0
            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;
            }
Exemple #2
0
        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;
        }
Exemple #3
0
        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();
            }
        }
Exemple #4
0
 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));
     }
 }
Exemple #5
0
            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);
            }
Exemple #6
0
        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];
        }
Exemple #7
0
        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);
            }
        }
Exemple #8
0
        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();
            }
        }
Exemple #9
0
        public FuzzyVariable <T> Get(T linguisticVar)
        {
            int idx = Array.IndexOf <EnumKey <T> >(this.enumValues, EnumKey <T> .From(linguisticVar));

            return(this._variables[idx]);
        }