Example #1
0
        public static void GradualCompression(ArrayList s, double ratio)
        {
            int newsize = Model.models[0].overallsize();

            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);
                newsize -= size;
                int nsize = models[0].overallsize();
                Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", i, size, newsize, nsize, sm.id1, sm.id2);
            }
        }
Example #2
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 (replaced.Contains(sm.id1) == false)
                {
                    s += ReplaceModel(sm.id2, sm.id1);
                    replaced.Add(sm.id1, sm.id2);
                    deleted.Add(sm.id2);
                }
                else
                {
                    int x = 0;
                }
            }
            return(s);
        }
Example #3
0
        public static ArrayList FindSimilairty()
        {
            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 (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);
                            Console.WriteLine("{0}\t{1}\t{2}\t{3}", i, j, sm.sim, sm.len);
                        }
                    }
                }
            }
            ar.Sort();
            return(ar);
        }
Example #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);
            }
        }