natix.SimilaritySearch.MultiNeighborhoodHash.Build C# (CSharp) Method

Build() public method

Creates an index for db using the specified number of instances.
public Build ( MetricDB db, Parameters uparams ) : void
db MetricDB
uparams Parameters
return void
        public void Build(MetricDB db, Parameters uparams)
        {
            var seed = RandomSets.GetRandomInt ();
            this.A = new NeighborhoodHash[uparams.NumberOfInstances];
            this.DB = db;
            this.A [0] = uparams.Index;
            for(int i = 1; i < uparams.NumberOfInstances; ++i) {
                Console.WriteLine ("==== creating {0}/{1} instances", i + 1, uparams.NumberOfInstances);
                var I = new NeighborhoodHash ();
                I.Build(db, uparams.Index.SymbolsPerHash, uparams.Index.NeighborhoodExpansion, new Random(seed + i));
                this.A [i] = I;
            }
        }

Usage Example

Esempio n. 1
0
        public static List<string> ExecuteMultiNeighborhoodHash(IndexArgumentSetup setup, string nick, double expected_recall, int max_instances)
        {
            var idxname = String.Format ("{0}/Index.MultiNeighborhoodHash.max_instances={1}-qarg={2}-expected-recall={3}", nick, max_instances, setup.QARG, expected_recall);
            var resname = Execute (setup, nick, idxname, (db) => {
                var parameters = MultiNeighborhoodHash.EstimateParameters (db, max_instances, (int)Math.Abs (setup.QARG), expected_recall, 96);
                /*if (parameters.NumberOfInstances == 1) {
                    idx = parameters.Index;
                } else {*/
                var IDX = new MultiNeighborhoodHash ();
                IDX.Build (db, parameters);
                return IDX;
            });
            var resnameList = new List<string> ();
            resnameList.Add (resname);

            resname = GetResultName (nick, idxname, setup, "Adaptive");
            resnameList.Add (resname);

            if (!File.Exists (resname)) {
                var idx = IndexGenericIO.Load (idxname);
                idx = new AdaptiveNeighborhoodHash(idx as MultiNeighborhoodHash);
                PerformSearch (resname, idx, idxname, setup);
            }
            return resnameList;
        }