Beispiel #1
0
        public static ArrayList FindSimilairty()
        {
            StreamWriter sw = new StreamWriter("C:/VLDBDemo_win/data/n/s1.txt");
            ArrayList    ar = new ArrayList();

            for (int i = 0; i < models.Length; i++)
            {
                for (int j = i + 1; j < models.Length; j++) // can be easily improved ( by starting from i+1)
                {
                    Model mi = models[i];
                    Model mj = models[j];
                    if (mi.len == -1)
                    {
                        continue;
                    }
                    if (mj.len == -1)
                    {
                        continue;
                    }
                    if (deleted.Contains(mi.id))
                    {
                        continue;
                    }
                    if (deleted.Contains(mj.id))
                    {
                        continue;
                    }
                    if (Model.comaprable(models[i], models[j]) == true)
                    {
                        if (mi.len >= 192)
                        {
                            SimItem sm = new SimItem();
                            sm.id1 = i;
                            sm.id2 = j;
                            sm.sim = sim(models[i], models[j]);
                            sm.len = mi.len;
                            ar.Add(sm);
                            sw.WriteLine("{0}\t{1}\t{2}\t{3}", i, j, sm.sim, sm.len);
                        }
                    }
                }
            }
            sw.Close();
            sw = new StreamWriter("C:/VLDBDemo_win/data/n/ss.txt");

            ar.Sort();
            foreach (SimItem sm in ar)
            {
                sw.WriteLine("{0}\t{1}\t{2}\t{3}", sm.id1, sm.id2, sm.sim, sm.len);
            }
            sw.Close();
            return(ar);
        }
Beispiel #2
0
        public static void GradualCompression(ArrayList s, double ratio)
        {
            StreamWriter sw = new StreamWriter("C:/VLDBDemo_win/data/n/c.txt");

            for (int i = 0; i < s.Count; i++)
            {
                SimItem sm = (SimItem)s[i];
                if (sm.sim / sm.len > ratio)
                {
                    break;
                }
                int size = Model.compress(s, i, 1);

                sw.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", i, size, newSize(), sm.id1, sm.id2);
            }
            sw.Close();
        }
Beispiel #3
0
        internal static int compress(ArrayList ar, int l, int len)
        {
            int s = 0;

            for (int i = l; i < len + l; i++)
            {
                SimItem sm = (SimItem)ar[i];
                if (deleted.Contains(sm.id2) == false)
                {
                    s += ReplaceModel(sm.id2, sm.id1);
                    replaced.Add(sm.id2, sm.id1);
                    deleted.Add(sm.id2);
                    getDependents(sm.id2);
                }

                /*else
                 * {
                 *  s += ReplaceModel(sm.id2, sm.id1);
                 *  int x=0;
                 * }*/
            }
            return(s);
        }
Beispiel #4
0
        /*
         * public int CompareTo(object obj)
         * {
         *  SimItem o = (SimItem)obj;
         *  if (sim > o.sim) return 1;
         *  else if (sim == o.sim)
         *  {
         *      if (len < o.len) return -1;
         *      else  return 1;
         *  }
         *  else return -1;
         * }
         */
        public int CompareTo(object obj)
        {
            SimItem o = (SimItem)obj;

            if (sim / len > o.sim / o.len)
            {
                return(1);
            }
            if (sim / len == o.sim / o.len)
            {
                if (len > o.len)
                {
                    return(1);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                return(-1);
            }
        }