Ejemplo n.º 1
0
        public List <WeightVector> GetW(WeightVectorEntities entities)
        {
            var query = from p in entities.WeightVectors orderby p.rating, p.star ascending
            select p;

            return(query.ToList());
        }
Ejemplo n.º 2
0
        public void getTree()
        {
            System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Environment.CurrentDirectory, @"Data\"));
            if (tree == null)
            {
                RTree.RTree <WeightVector> tree = SaveDataController.ReadFromBinaryFile <RTree.RTree <WeightVector> >(System.IO.Path.Combine(Environment.CurrentDirectory, @"Data\", fileName));
                //not created before
                tree.locker = new System.Threading.ReaderWriterLock();
                if (tree.Count == 0)
                {
                    //query database
                    WeightVectorEntities entities = new WeightVectorEntities();
                    var query = from p in entities.WeightVectors
                                select p;
                    List <WeightVector> listItem = query.ToList();
                    tree = new RTree.RTree <WeightVector>(listItem.Count > 9? 9:listItem.Count / 2, 2);
                    int count = 0;
                    foreach (WeightVector p in listItem)
                    {
                        count++;
                        Debug.WriteLine(count);
                        RTree.Rectangle rect = new RTree.Rectangle((float)p.rating, (float)p.star, (float)p.rating, (float)p.star, 0, 0);
                        tree.Add(rect, p);
                    }

                    SaveDataController.WriteToBinaryFile(System.IO.Path.Combine(Environment.CurrentDirectory, @"Data\", fileName), tree);
                }
                this.tree = tree;
            }
        }
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            var                  watch     = System.Diagnostics.Stopwatch.StartNew();
            DataPoint            point     = new DataPoint(Double.Parse(this.rating.Text), Double.Parse(this.star.Text));
            WeightVectorEntities entities  = new WeightVectorEntities();
            DATNEntities         entities2 = new DATNEntities();
            List <DataPoint>     listS     = GetS(entities2);
            List <WeightVector>  listW     = GetW(entities);

            entities.Dispose();
            entities2.Dispose();
            KeyValuePair <int, HashSet <WeightVector> > result = rtaController.RTA(listS, listW, point, Int32.Parse(this.rank.Text));

            watch.Stop();
            fillTable(result.Value);
            var elapsedMs = watch.ElapsedMilliseconds;

            chart1.Series[1].Points.AddY(elapsedMs);
            chart2.Series[1].Points.AddY(result.Key);
            MessageBox.Show("Done");
        }