Exemplo n.º 1
0
        public DiscreteFuzzySetBLL Discretize(ContinuousFuzzySetBLL ConFS, double StartPoint, double epsilon)
        {
            DiscreteFuzzySetBLL DiscFS = new DiscreteFuzzySetBLL();
            DiscFS.FuzzySetName = ConFS.FuzzySetName;
            DiscFS.FuzzySet = ConFS.FuzzySet;

            for (double value = StartPoint; value <= ConFS.Bottom_Right; value += epsilon)
            {
                double membership = ConFS.GetMembershipAt(value);
                DiscFS.AddPoint(value, membership);
            }

            return DiscFS;
        }
Exemplo n.º 2
0
        public int DeleteConFs(ContinuousFuzzySetBLL conFs)
        {
            try
            {
                int result = 0;

                if (IsExistFSName(conFs.FuzzySetName))//Delete Object
                {
                    var _conFs = db.ContinuousLibraries.FirstOrDefault(id => id.LanguisticLabel == conFs.FuzzySetName);

                    db.DeleteObject(_conFs);
                    return result = db.SaveChanges();
                }
                else//Do nothing
                {
                    return result = -1;
                }
            }
            catch (SQLiteException ex)
            {
                //throw new Exception(ex.Message);
                return -1;
            }
        }
Exemplo n.º 3
0
        private FzTupleEntity IsSatisfyExpression(String[] splitedList, FzTupleEntity tuple)
        {
            FzTupleEntity result = new FzTupleEntity() { ValuesOnPerRow = tuple.ValuesOnPerRow };

            int indexAttr = Convert.ToInt32(splitedList[0]);
            String dataType = this._attributes[indexAttr].DataType.DataType;
            Object value = tuple.ValuesOnPerRow[indexAttr];//we don't know the data type of value
            int count = 0;

            DiscreteFuzzySetBLL disFS = new DiscreteFuzzySetBLL().GetByName(splitedList[2]);//2 is value input
            ContinuousFuzzySetBLL conFS = new ContinuousFuzzySetBLL().GetByName(splitedList[2]);

            if (conFS != null)//continuous fuzzy set is priorer than discrete fuzzy set
            {
                Double uValue = FuzzyCompare(Convert.ToDouble(value), conFS, splitedList[1]);//1 is operator
                Double uRelation = Convert.ToDouble(tuple.ValuesOnPerRow[tuple.ValuesOnPerRow.Count - 1]);
                if (uValue != 0)
                {
                    result.ValuesOnPerRow[tuple.ValuesOnPerRow.Count - 1] = Math.Min(uValue, uRelation);
                    count++;
                }
            }

            if (disFS != null && conFS == null)
            {
                Double uValue = FuzzyCompare(Convert.ToDouble(value), disFS, splitedList[1]);
                Double uRelation = Convert.ToDouble(tuple.ValuesOnPerRow[tuple.ValuesOnPerRow.Count - 1]);
                if (uValue != 0)
                {
                    result.ValuesOnPerRow[tuple.ValuesOnPerRow.Count - 1] = Math.Min(uValue, uRelation);
                    count++;
                }
            }

            if (disFS == null && conFS == null)
            {
                if (ObjectCompare(value, splitedList[2], splitedList[1], dataType))
                {
                    count++;
                }
            }

            if (count == 1)//it mean the tuple is satisfied with all the compare operative
            {
                return result;
            }

            return null;
        }
Exemplo n.º 4
0
        private Double FuzzyCompare(Double value, ContinuousFuzzySetBLL set, String opr)
        {
            Double result = 0;

            switch (opr)
            {
                case "<"://
                    if (value < set.Bottom_Left)
                    {
                        result = 1;
                    }
                    return result;

                case ">":
                    if (value > set.Bottom_Right)
                    {
                        result = 1;
                    }
                    return result;

                case "<=":
                    if (value <= set.Bottom_Right)
                    {
                        result = 1;//select
                    }
                    return result;

                case ">=":
                    if (value >= set.Bottom_Left)
                    {
                        result = 1;//select
                    }
                    return result;

                case "=":
                    if (value >= set.Bottom_Left && value <= set.Bottom_Right)
                    {
                        result = set.GetMembershipAt(value);
                    }
                    return result;

                case "!="://No need to get the membership
                    if (value < set.Bottom_Left && value > set.Bottom_Right)
                    {
                        result = 1;//selet the tuple
                    }
                    return result;
            }

            return result;
        }
Exemplo n.º 5
0
        private List<ContinuousFuzzySetBLL> GetSelectedRows()
        {
            List<ContinuousFuzzySetBLL> result = new List<ContinuousFuzzySetBLL>();

            for (int i = 0; i < gridView1.DataRowCount; i++)
            {
                if (gridView1.GetRowCellValue(i, "check").ToString() == "True")
                {
                    ContinuousFuzzySetBLL set = new ContinuousFuzzySetBLL();
                    set.FuzzySetName = gridView1.GetRowCellValue(i, "name").ToString();
                    set.Bottom_Left = Convert.ToDouble(gridView1.GetRowCellValue(i, "bottomLeft"));
                    set.Top_Left = Convert.ToDouble(gridView1.GetRowCellValue(i, "topLeft"));
                    set.Top_Right = Convert.ToDouble(gridView1.GetRowCellValue(i, "topRight"));
                    set.Bottom_Right = Convert.ToDouble(gridView1.GetRowCellValue(i, "bottomRight"));

                    result.Add(set);
                }
            }

            return result;
        }
Exemplo n.º 6
0
        public List<ContinuousFuzzySetBLL> GetAllConFS()
        {
            try
            {
                var con = from c in db.ContinuousLibraries
                          select c;

                List<ContinuousFuzzySetBLL> result = new List<ContinuousFuzzySetBLL>();

                foreach (var item in con.ToList())
                {
                    ContinuousFuzzySetBLL conFs = new ContinuousFuzzySetBLL();
                    conFs.FuzzySetName = item.LanguisticLabel;
                    conFs.Bottom_Left = item.BottomLeft;
                    conFs.Top_Left = item.TopLeft;
                    conFs.Bottom_Right = item.BottomRight;
                    conFs.Top_Right = item.TopRight;

                    result.Add(conFs);
                }

                return result;
            }
            catch
            {
                //throw new Exception("ERROR:\n" + ex.Message);
                return null;
            }
        }
Exemplo n.º 7
0
        public int UpdateConFs(ContinuousFuzzySetBLL conFs)
        {
            try
            {
                int result = 0;

                if (!IsExistFSName(conFs.FuzzySetName))//Add new object
                {
                    ContinuousLibrary child = new ContinuousLibrary();
                    child.LanguisticLabel = conFs.FuzzySetName;
                    child.BottomLeft = conFs.Bottom_Left;
                    child.TopLeft = conFs.Top_Left;
                    child.BottomRight = conFs.Bottom_Right;
                    child.TopRight = conFs.Top_Right;

                    db.AddToContinuousLibraries(child);
                    return result = db.SaveChanges(true);
                }
                else//Just update value
                {
                    var _conFs = db.ContinuousLibraries.FirstOrDefault(id => id.LanguisticLabel == conFs.FuzzySetName);
                    _conFs.LanguisticLabel = conFs.FuzzySetName;
                    _conFs.BottomLeft = conFs.Bottom_Left;
                    _conFs.TopLeft = conFs.Top_Left;
                    _conFs.BottomRight = conFs.Bottom_Right;
                    _conFs.TopRight = conFs.Top_Right;

                    return result = db.SaveChanges();
                }
            }
            catch (SQLiteException ex)
            {
                //throw new Exception(ex.Message);
                return -1;
            }
        }
Exemplo n.º 8
0
        public ContinuousFuzzySetBLL GetConFsByName(String name)
        {
            try
            {
                var con = db.ContinuousLibraries.SingleOrDefault(id => id.LanguisticLabel == name);
                ContinuousFuzzySetBLL conFs = new ContinuousFuzzySetBLL();

                if (con != null)
                {
                    conFs.FuzzySetName = con.LanguisticLabel;
                    conFs.Bottom_Left = con.BottomLeft;
                    conFs.Top_Left = con.TopLeft;
                    conFs.Bottom_Right = con.BottomRight;
                    conFs.Top_Right = con.TopRight;
                }
                else
                    conFs = null;

                return conFs;
            }
            catch (SQLiteException ex)
            {
                //throw new Exception("ERROR:\n" + ex.Message);
                return null;
            }
        }