InternalBuild() public method

public InternalBuild ( ANNISetup setup, int leader_num_centers, double leader_review_prob, MetricDB db, int num_indexes ) : BuildSearchCost
setup ANNISetup
leader_num_centers int
leader_review_prob double
db MetricDB
num_indexes int
return BuildSearchCost
Esempio n. 1
0
File: FANNI.cs Progetto: sadit/natix
        public virtual void Build(MetricDB db, ANNISetup setup)
        {
            // num_build_processors = 1;
            this.DB = db;
            var rows = new List<ANNI> ();

            var pivsel = new PivotSelectorRandom(db.Count, RandomSets.GetRandom());

            this.leader = new NANNI();
            var ilc = new ANNI();
            var cost = ilc.InternalBuild (setup, 0, 1.0, db, 2);
            this.leader.Build (ilc);
            int m = this.leader.clusters.Count;
            double review_prob = cost.SingleCost - m; review_prob /= this.DB.Count;
            var min_prob = Math.Sqrt (this.DB.Count) / this.DB.Count;

            while (review_prob > min_prob) {
                var row = new ANNI ();
                rows.Add (row);
                var _cost = row.InternalBuild (setup, m, review_prob, db, 2);
                var _m = row.ACT.Count;
                review_prob *= (_cost.SingleCost - _m) / this.DB.Count;
            }
            this.rows = rows.ToArray ();
        }
Esempio n. 2
0
        public virtual void Build(MetricDB db, ANNISetup setup, int num_indexes, int num_tasks = -1)
        {
            // num_build_processors = 1;
            this.DB = db;
            --num_indexes;
            this.rows = new ANNI[num_indexes];

            var pivsel = new PivotSelectorRandom(db.Count, RandomSets.GetRandom());

            this.leader = new NANNI();
            var ilc = new ANNI();
            var cost = ilc.InternalBuild (setup, 0, 1.0, db, 2);
            this.leader.Build (ilc);
            int m = this.leader.clusters.Count;
            double review_prob = cost.SingleCost - m; review_prob /= this.DB.Count;

            //			ParallelOptions ops = new ParallelOptions ();
            //			ops.MaxDegreeOfParallelism = num_tasks;
            //			Parallel.For (0, num_indexes, ops, (int i) => {
            //				this.rows [i] = new ILC ();
            //				this.rows [i].InternalBuild (m, review_prob, db, num_indexes, pivsel);
            //			});

            Console.WriteLine ("====> num_indexes: {0}", num_indexes);
            LongParallel.For (0, num_indexes, (int i) => {
                this.rows [i] = new ANNI ();
                this.rows [i].InternalBuild (setup, m, review_prob, db, num_indexes);
            }, num_tasks);
        }