Example #1
0
        //private Double FuzzyCompare(Double value, DiscreteFuzzySetBLL set, String opr)
        //{
        //    Double result = 0;
        //    Double max = set.GetMaxValue();
        //    Double min = set.GetMinValue();
        //    Double membership = set.GetMembershipAt(value);
        //    Boolean isMember = set.IsMember(value);
        //    switch (opr)
        //    {
        //        case "→":
        //            if (isMember)
        //                result = membership;
        //            return result;
        //        case "<"://
        //            if ( value < min)
        //                result = 1;
        //            return result;
        //        case ">":
        //            if (value > max)
        //                result = 1;
        //            return result;
        //        case "<=":
        //            if (value < min)
        //                result = 1;
        //            if (isMember)
        //                result = membership;
        //            return result;
        //        case ">=":
        //            if (value > max)
        //                result = 1;//select
        //            if (isMember)
        //                result = membership;
        //            return result;
        //        case "=":
        //            if (isMember)
        //                result = membership;
        //            return result;
        //        case "!="://No need to get the membership
        //            if (!isMember)
        //                result = 1;
        //            return result;
        //    }
        //    return result;
        //}
        private Double FuzzyCompare(Double value, DisFS set, String opr)
        {
            Double result = 0;
            Double max = set.GetMaxValue();
            Double min = set.GetMinValue();
            Double membership = set.GetMembershipAt(value);
            Boolean isMember = set.IsMember(value);

            switch (opr)
            {
                case "→":
                    if (isMember)
                        result = membership;
                    return result;
                case "<"://
                    if (value < min)
                        result = 1;
                    return result;

                case ">":
                    if (value > max)
                        result = 1;
                    return result;

                case "<=":

                    if (value < min)
                        result = 1;
                    if (isMember)
                        result = membership;
                    return result;

                case ">=":
                    if (value > max)
                        result = 1;//select
                    if (isMember)
                        result = membership;
                    return result;

                case "=":
                    if (isMember)
                        result = membership;
                    return result;

                case "!="://No need to get the membership
                    if (!isMember)
                        result = 1;
                    return result;
            }

            return result;
        }
Example #2
0
        public DisFS ReadEachDisFS(string path)
        {
            DisFS result = new DisFS();
            try
            {
                List<String> list = new List<string>();
                using (StreamReader reader = new StreamReader(path))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)//Only have two lines
                    {
                        list.Add(line); // Add to list.
                    }
                }

                result.Name = FuzzySetName(path);
                result.V = list[0];
                result.M = list[1];
                result.ValueSet = SplitString(list[0]);
                result.MembershipSet = SplitString(list[1]);

                return result;
            }
            catch (Exception ex)
            {
                return null;
            }
        }