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 (); }
public void Build(MetricDB db, ANNISetup setup, int num_indexes, int num_tasks = -1) { // num_build_processors = 1; this.DB = db; var _rows = new ANNI[num_indexes]; LongParallel.For (0, num_indexes, (int i) => { _rows [i] = new ANNI (); _rows [i].InternalBuild (setup, 0, 1.0, db, num_indexes); }, num_tasks); // ParallelOptions ops = new ParallelOptions (); // ops.MaxDegreeOfParallelism = num_processors; // Parallel.For (0, num_indexes, ops, (int i) => { // _rows [i] = new ILC (); // _rows [i].Build (db, num_indexes, pivsel); // }); this.leader = new NANNI(); this.leader.Build(_rows [0]); this.rows = new ANNI[num_indexes - 1]; for (int i = 1; i < num_indexes; ++i) { this.rows[i - 1] = _rows[i]; } }
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); }
public static ANNI CreateANNI(string dbname, int expected_k) { MetricDB db = SpaceGenericIO.Load (dbname); ANNI ilc = new ANNI (); var annisetup = new ANNISetup (db.Count, expected_k); ilc.Build (db, annisetup); return ilc; }
public void Build(ANNI ilc) { this.DB = ilc.DB; int n = this.DB.Count; this.clusters.Clear(); foreach (var objID in ilc.ACT) { var node = new Node(); node.objID = objID; this.clusters.Add (node); } for (int objID = 0; objID < n; ++objID) { var c = ilc.CT [objID]; if (c == -1) continue; this.clusters[c].Add (objID, ilc.DT [objID]); } }