Base approach class to extend
        public ApproachFactory(string collection, int prefixLength, string expType, string[] allArgs, bool isDebug = false)
        {
            // Determine which approach to create
            _runId = collection + '-' + expType;

            if (expType == "bl-w")
                _runId += allArgs[4]; // Append the number of days the window is over

            if (expType == "ntb")
                _runId += allArgs[4] + "-" + allArgs[5]; // Append the non temporal bucket parameters

            if (expType == "sgdlrnomntb") // Multiple non-overlapping NTBs with stochastic gradient descent linear regression, args are comma separated
                _runId += allArgs[4] + "-" + allArgs[5] + "-t" + allArgs[6]; // Append the non temporal bucket parameters along with train between queries last parameter (format: aol 2 mntb 2006-03-01 500,1000 500,1000 100)

            // Ensure the run output file doesn't already exist
            if (!isDebug && File.Exists(Utilities.DataDirectory + prefixLength + "chars-" + _runId + ".txt"))
            {
                Console.WriteLine("Output file already exists, exiting.");
                Environment.Exit(0); // Exit now
            }

            // Setup the approach
            if (!isDebug)
                _evalOutput = new StandardEvalOutput(new FileInfo(Utilities.DataDirectory + prefixLength + "chars-" + _runId + ".txt"), _runId, prefixLength); // new StandardEvalOutput(new FileInfo("aol_wiki_all_history_" + prefixChars + "_baseline_charprefix.txt"), runName, prefixChars);
            else
                _evalOutput = new StandardEvalOutput(null, _runId, prefixLength, true); // Debug for event-based output rather than file output

            if (expType == "bl-a")
                _approach = new BaselineAllQueryLog<BaseIndexEntry>(prefixLength, _evalOutput, null);
            else if (expType == "bl-w")
                _approach = new BaselineWindowQueryLog<BaseIndexEntry>(Convert.ToInt32(allArgs[4]), prefixLength, _evalOutput, null);
            else if (expType == "ntb")
            {
                _approach = new NonTemporalBucketApproach(Convert.ToInt32(allArgs[4]), Convert.ToInt32(allArgs[5]), prefixLength, _evalOutput, null);
            }
            else if (expType == "sgdlrnomntb")
            {
                _approach = new noSGDLRMNTB(
                    allArgs[4].Split(',').Select(s => int.Parse(s)).ToArray(),
                    allArgs[5].Split(',').Select(s => int.Parse(s)).ToArray(),
                    Convert.ToInt32(allArgs[6]),
                    Utilities.DataDirectory + collection + "-queries.txt",
                    prefixLength,
                    _evalOutput,
                    null,
                    Convert.ToInt32(allArgs[7]));
            }
            else
            {
                Console.WriteLine("Invalid experiment type, must be bl-a, bl-w, ntb or sgdlrnomntb.");
                Environment.Exit(0);
            }

            // Load the one-off queries for optimisation in some cases
            OneOffQueries ofq = new OneOffQueries(new FileInfo(Utilities.DataDirectory + collection + "-oneoffqueries.txt"));
            _approach.OneOffQueries = ofq;
        }
Exemple #2
0
        /// <summary>
        /// Begin experiment in format: QACExperimenter.exe {collection:[aol|msn|sog]} {prefixLength} {experimentType[bl-a(baseline-all)|bl-w(baseline-window)|wiki(wiki-weighted)]} {startDate:yyyy-mm-dd} {param1:e.g.WindowNDays} ...
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            // Min 3 args
            if (args.Length < 4)
            {
                Console.WriteLine("Not enough parameters provided.");
                return;
            }

            // Determine the arguments
            string collection = args[0];
            int prefixChars = Convert.ToInt32(args[1]);
            string experimentType = args[2];
            DateTime startDate = new DateTime(Convert.ToInt32((args[3].Split('-'))[0]), Convert.ToInt32((args[3].Split('-'))[1]), Convert.ToInt32((args[3].Split('-'))[2]));

            FileInfo queryLog = new FileInfo(Utilities.DataDirectory + collection + "-queries.txt");
            FileInfo interleavedInput = new FileInfo(Utilities.DataDirectory + collection + "-interleavedinput.txt");
            if (!interleavedInput.Exists)
                interleavedInput = null; // Don't load if the interleaved input is null

            // Setup the data model and begin reading
            DataModel dm = new DataModel(queryLog, interleavedInput, startDate, 600000000); // I.e. all for now!
            dm.OnQuerySubmitted += dm_OnQuerySubmitted;
            dm.OnInterleavedInput += dm_OnInterleavedInput;

            // Setup the approach
            ApproachFactory af = new ApproachFactory(collection, prefixChars, experimentType, args);
            _completionApproach = af.Approach;

            // Begin reading form the data model
            dm.BeginReading();

            // Finish up the evaluation
            _completionApproach.WaitForFinish();
            af.EvalOutput.FinishOutput();

            // Output the final MRR
            Console.WriteLine("Final MRR: " + Evaluation.StandardEvalOutput.CURRENT_MRR.ToString("F4"));
        }