Build() публичный Метод

public Build ( KnrSeqSearch other ) : void
other KnrSeqSearch
Результат void
Пример #1
0
        public static List<string> ExecuteKNRSEQ(IndexArgumentSetup setup, string nick, int numrefs, int k, double maxcand_ratio)
        {
            var idxname = String.Format ("{0}/Index.knrseq-{1}-{2}", nick, numrefs, k);
            MetricDB db = SpaceGenericIO.Load (setup.BINARY_DATABASE);
            Index idx;
            var suffix = "";

            var resnamelist = new List<string> ();
            if (!File.Exists (idxname)) {
                Console.WriteLine ("*** creating index {0}", idxname);
                var s = DateTime.Now.Ticks;
                var c = db.NumberDistances;
                var IDX = new KnrSeqSearch ();
                var refsDB = new SampleSpace("", db, numrefs);
                var refsIDX = new EPTable ();
                refsIDX.Build(refsDB, 4, (_db, _rand) => new EPListOptimizedA(_db, 4, _rand));
                if (k == 0) {
                    k = KnrEstimateParameters.EstimateKnrEnsuringSharedNeighborhoods (db, refsIDX, (int)Math.Abs (setup.QARG));
                    suffix = String.Format ("estimated-K={0}.", k);
                }
                IDX.Build (db, refsIDX, k, int.MaxValue);
                SaveConstructionTime (idxname, DateTime.Now.Ticks - s, db.NumberDistances - c);
                IndexGenericIO.Save (idxname, IDX);
                idx = IDX;
            } else {
                Console.WriteLine ("*** loading index {0}", idxname);
                idx = IndexGenericIO.Load (idxname);
                if (k == 0) {
                    var _idx = idx as KnrSeqSearch;
                    suffix = String.Format ("estimated-K={0}.", _idx.K);
                }
            }
            string resname;
            // PPIndex
            resname = GetResultName (nick, idxname, setup, String.Format(suffix + "maxcand={0}.PPI", maxcand_ratio));
            resnamelist.Add(resname);
            if (!File.Exists (resname)) {
                var knr = idx as KnrSeqSearch;
                knr.MAXCAND = (int)(idx.DB.Count * maxcand_ratio);
                PerformSearch (resname, knr, idxname, setup);
            }
            // KnrSeqSearchCosine
            resname = GetResultName (nick, idxname, setup, String.Format(suffix + "maxcand={0}.COS", maxcand_ratio));
            resnamelist.Add(resname);
            if (!File.Exists (resname)) {
                var knr = new KnrSeqSearchCosine(idx as KnrSeqSearch);
                knr.MAXCAND = (int)(idx.DB.Count * maxcand_ratio);
                PerformSearch (resname, knr, idxname, setup);
            }
            // KnrSeqSearchFootrule
            resname = GetResultName (nick, idxname, setup, String.Format(suffix + "maxcand={0}.FOOTRULE", maxcand_ratio));
            resnamelist.Add(resname);
            if (!File.Exists (resname)) {
                var knr = new KnrSeqSearchFootrule(idx as KnrSeqSearch);
                knr.MAXCAND = (int)(idx.DB.Count * maxcand_ratio);
                PerformSearch (resname, knr, idxname, setup);
            }
            // KnrSeqSearchJaccLCS
            resname = GetResultName (nick, idxname, setup, String.Format(suffix + "maxcand={0}.JACCLCS", maxcand_ratio));
            resnamelist.Add(resname);
            if (!File.Exists (resname)) {
                var knr = new KnrSeqSearchJaccLCS(idx as KnrSeqSearch);
                knr.MAXCAND = (int)(idx.DB.Count * maxcand_ratio);
                PerformSearch (resname, knr, idxname, setup);
            }
            // KnrSeqSearchLCSv3
            resname = GetResultName (nick, idxname, setup, String.Format(suffix + "maxcand={0}.LCSv3", maxcand_ratio));
            resnamelist.Add(resname);
            if (!File.Exists (resname)) {
                var knr = new KnrSeqSearchLCSv3(idx as KnrSeqSearch);
                knr.MAXCAND = (int)(idx.DB.Count * maxcand_ratio);
                PerformSearch (resname, knr, idxname, setup);
            }
            // NAPP
            foreach (var ksearch in setup.KNR_KSEARCH) {
                var knr = new NAPP(idx as KnrSeqSearch);
                knr.MAXCAND = (int)(idx.DB.Count * maxcand_ratio);
                resname = GetResultName (nick, idxname, setup, String.Format(suffix + "maxcand={0}.NAPP.ksearch={1}", maxcand_ratio, ksearch));
                resnamelist.Add(resname);
                if (!File.Exists (resname)) {
                    PerformSearch (resname, knr, idxname, setup);
                }
            }
            return resnamelist;
        }
Пример #2
0
        public void Test(string nick, MetricDB db, string queries, int num_centers, int num_perms, int num_refs)
        {
            var qstream = new QueryStream (queries);
            var reslist = new List<string> ();
            // Exhaustive search
            {
                Sequential seq = new Sequential ();
                seq.Build (db);
                var idxname = "Index.Sequential." + nick;
                IndexGenericIO.Save (idxname, seq);
                var resname = "Res." + idxname + "." + queries;
                if (!File.Exists (resname)) {
                    Commands.Search (seq, qstream.Iterate (), new ShellSearchOptions (queries, idxname, resname));
                }
                reslist.Add (resname);
            }

            ///
            /// The List of Clusters and variants
            ///

            // LC_RNN
            reslist.Add (this.TestLC ("Index.LC_RNN." + nick, db, num_centers, new LC_RNN (), queries, qstream));
            // LC
            reslist.Add (this.TestLC ("Index.LC." + nick, db, num_centers, new LC (), queries, qstream));
            // LC_IRNN
            reslist.Add (this.TestLC ("Index.LC_IRNN." + nick, db, num_centers, new LC_IRNN (), queries, qstream));
            // LC_PRNN
            reslist.Add (this.TestLC ("Index.LC_PRNN." + nick, db, num_centers, new LC_PRNN (), queries, qstream));
            // LC_ParallelBuild
            reslist.Add (this.TestLC ("Index.LC_ParallelBuild." + nick, db, num_centers, new LC_ParallelBuild (), queries, qstream));

            ///
            /// Permutation Based Indexes
            ///

            // Permutations
            reslist.Add (this.TestPI ("Index.Perms." + nick, db, num_perms, new Perms (), queries, qstream));
            // Brief Index
            reslist.Add (this.TestPI ("Index.BinPerms." + nick, db, num_perms, new BinPerms (), queries, qstream));
            // BinPermsTwoBits
            reslist.Add (this.TestPI ("Index.BinPermsTwoBits." + nick, db, num_perms, new BinPermsTwoBit (), queries, qstream));
            ///
            /// KNR
            ///

            {
                KnrSeqSearch idx;
                var idxname = "Index.KnrSeqSearch." + nick;
                if (File.Exists (idxname)) {
                    idx = (KnrSeqSearch)IndexGenericIO.Load (idxname);
                } else {
                    Console.WriteLine ("** Starting construction of '{0}'", idxname);
                    var knr = new KnrSeqSearch ();
                    var sample = RandomSets.GetRandomSubSet (num_refs, db.Count);
                    var refsdb = new SampleSpace ("", db, sample);
                    var refsidx = new LC ();
                    refsidx.Build (refsdb, refsdb.Count / 10);
                    knr.Build (db, refsidx, 7);
                    IndexGenericIO.Save (idxname, knr);
                    idx = knr;
                }
                idx.MAXCAND = 1024;
                this.TestKNR(idx, idxname, queries, num_refs, reslist, (I) => I);
                Console.WriteLine ("==== Working on a permuted space");
                idxname = idxname + ".proximity-sorted";
                if (!File.Exists(idxname)) {
                    idx = idx.GetSortedByPrefix();
                    idx.MAXCAND = 1024;
                    IndexGenericIO.Save(idxname, idx);
                } else {
                    idx = (KnrSeqSearch)IndexGenericIO.Load(idxname);
                }
                this.TestKNR(idx, idxname, queries, num_refs, reslist, (I) => new PermutedIndex(I));
            }
            reslist.Add("--horizontal");
            Commands.Check(reslist);
        }
Пример #3
0
 public void BuildApprox(MetricDB db, Random rand, int num_refs, int K=7, int maxcand=1024, SequenceBuilder seq_builder = null)
 {
     var sample = new SampleSpace ("", db, num_refs);
     var inner = new KnrSeqSearch ();
     inner.Build (sample, rand, 1024, K, int.MaxValue);
     this.Build (db, new KnrSeqSearchFootrule(inner), K, maxcand, seq_builder);
 }