예제 #1
0
파일: FLC.cs 프로젝트: nalytools/FuzzyLogic
        private double Centroid(List <FuzzyNumber> nums, LingVariable variable)
        {
            double stepN    = 17;
            double start    = variable.Range[0];
            double end      = variable.Range[1];
            double step     = (end - start) / (stepN - 1);
            double uppersum = 0;
            double lowersum = 0;

            for (int i = 0; i < nums.Count; i++)
            {
                MemberShipFunction mf = variable.getMFbyName(nums[i].MemberShipName);
                for (double j = start; j < end; j = step + j)
                {
                    double value = mf.getOutput(j);
                    if (value > 0)
                    {
                        if (value < nums[i].FuzzyValue)
                        {
                            uppersum = value * j + uppersum;
                            lowersum = value + lowersum;
                        }
                        else
                        {
                            uppersum = nums[i].FuzzyValue * j + uppersum;
                            lowersum = nums[i].FuzzyValue + lowersum;
                        }
                    }
                }
            }
            return(uppersum / lowersum);
        }
예제 #2
0
 public void addMF(MemberShipFunction mf)
 {
     if (mf != null)
     {
         _funcs.Add(mf);
     }
 }
예제 #3
0
 public bool removeMF(MemberShipFunction mf)
 {
     if (mf != null)
     {
         return(_funcs.Remove(mf));
     }
     return(false);
 }
예제 #4
0
파일: FLC.cs 프로젝트: nalytools/FuzzyLogic
        private double MaxHeightDeFuzzifcation(List <FuzzyNumber> nums, LingVariable variable)
        {
            double lowvalue  = 0;
            double highvalue = 0;

            for (int i = 0; i < nums.Count; i++)
            {
                MemberShipFunction mf = variable.getMFbyName(nums[i].MemberShipName);
                highvalue = ((mf.CenterOfMass * getImplication(nums[i].FuzzyValue, mf.getOutput(mf.CenterOfMass))) / (mf.Spread * mf.Spread)) + highvalue;
                lowvalue  = (getImplication(nums[i].FuzzyValue, mf.getOutput(mf.CenterOfMass)) / (mf.Spread * mf.Spread)) + lowvalue;
            }
            return(highvalue / lowvalue);
        }