public void Run() { if (D == null) { throw new InvalidOperationException("Run ConfigureEvolver() first"); } if (_validate) { D.VerifyOutput(); } if (_outputBaseline) { //Run a simulation including all features to find the best combination of parameters for the particular classifier T baseline = new T(); string basePath = OptoGlobals.EnvironmentTag + "/" + OptoGlobals.DataSetName + "/" + baseline.GetToken + "Baseline"; EvoOptimizerProgram <T> baseProgram = new EvoOptimizerProgram <T>(); baseProgram.MaxGen = 100; baseProgram.SaveAfterGens = 25; baseProgram.PopSize = 50; baseProgram.IncludeAllFeatures = true; baseProgram.OutputFileStem = basePath; baseProgram.Noload = true; baseProgram._outputBaseline = false; baseProgram.ConfigureAndRun(); } Stopwatch sw = new Stopwatch(); _running = true; for (int x = 0; x < _maxGen; ++x) { sw.Start(); D.AdvanceGeneration(); Debug.WriteLine("Elapsed time for generation " + x + " = " + sw.ElapsedMilliseconds + " ms"); Console.WriteLine("Elapsed time for generation " + x + " = " + sw.ElapsedMilliseconds + " ms"); double sum = 0, count = 0; foreach (T t in D.Population) { sum += t.Fitness; count += 1; } Console.WriteLine("Best Fitness = " + D.Population[0].Fitness + " \n Average fitness = " + D.AverageFitness); if (x % _saveAfterGens == 0) { D.DumpLookupToFile(OutputFileStem); } sw.Reset(); } D.DumpLookupToFile(OutputFileStem); OutputFileStem = null; //Console.ReadLine(); }
static void Main(string[] args) { string compTagFile = @"..\..\compTag.txt"; if (System.IO.File.Exists(compTagFile)) { OptoGlobals.LoadTagFromFile(compTagFile); } else { using (System.IO.StreamWriter fout = new System.IO.StreamWriter(compTagFile)){ fout.WriteLine("NoTag"); } } OptoGlobals.IsDebugMode = false; // Create the MATLAB instance String GlobalPath = "../../../Data/Hackathon/DataSetConfigSquish.csv"; int maxGen = 100, saveAfterGens = 25, popSize = 50, baseCompUB = 10, maxComp = 2000; if (args.Length >= 2) { GlobalPath = args[1]; } for (int i = 2; i < args.Length; ++i) { switch (args[i].ToLower()) { case "path": case "-p": GlobalPath = args[++i]; break; case "gen": case "-g": maxGen = Int32.Parse(args[++i]); break; case "save": case "-r": saveAfterGens = Int32.Parse(args[++i]); break; case "population": case "-pop": saveAfterGens = Int32.Parse(args[++i]); break; case "compub": case "-c": baseCompUB = Int32.Parse(args[++i]); break; case "maxcomp": case "-m": maxComp = Int32.Parse(args[++i]); break; } } OptoGlobals.ConfigureForDataset(GlobalPath); double[] poot = { OptoGlobals.RNG.NextDouble(), OptoGlobals.RNG.NextDouble(), OptoGlobals.RNG.NextDouble(), OptoGlobals.RNG.NextDouble(), OptoGlobals.RNG.NextDouble(), OptoGlobals.RNG.NextDouble(), OptoGlobals.RNG.NextDouble(), OptoGlobals.RNG.NextDouble(), OptoGlobals.RNG.NextDouble(), OptoGlobals.RNG.NextDouble() }; object pootwrap = poot; //Hunter x = new Hunter(); double nerp; Daedalus D = new Daedalus(); //x.Vote(pootwrap, out nerp); CTreeOptimizer.CTreeOptimizer.RewriteBitLengths(); EvoOptimizerProgram <CTreeOptimizer.CTreeOptimizer> decisionTreeProgram = new EvoOptimizerProgram <CTreeOptimizer.CTreeOptimizer>(); decisionTreeProgram.MaxGen = maxGen; decisionTreeProgram.SaveAfterGens = saveAfterGens; decisionTreeProgram.PopSize = popSize; decisionTreeProgram.OutputBaseline = false; MulticlassNBOptimizer.MulticlassNBOptimizer.RewriteBits(); EvoOptimizerProgram <MulticlassNBOptimizer.MulticlassNBOptimizer> naiveBayesProgram = new EvoOptimizerProgram <MulticlassNBOptimizer.MulticlassNBOptimizer>(); naiveBayesProgram.MaxGen = maxGen; naiveBayesProgram.SaveAfterGens = saveAfterGens; naiveBayesProgram.PopSize = popSize; naiveBayesProgram.OutputBaseline = false; //Configure the program here- set things like multi-threading, etc, if desired D.MaxGen = maxGen * 10; D.RecordInterval = saveAfterGens; D.PopSize = popSize * 10; D.InitialComplexityUpperBound = baseCompUB; D.MaxCellComplexity = maxComp; D.ConfigureCellDelegatesForDatabase(); //System.Threading.Thread t = new System.Threading.Thread(() => D.Run()); //t.Start(); //D.Run(); naiveBayesProgram.ConfigureAndRun(); decisionTreeProgram.ConfigureAndRun(); /*MulticlassNBOptimizer.MulticlassNBOptimizer bestNb = new MulticlassNBOptimizer.MulticlassNBOptimizer("1101110111010101001010100000101111000111000010101110101011011111111100011011100"); * bestNb.Eval(); * * OptoGlobals.readInSpecialTestSet(); * * bestNb.Eval(); * using(StreamWriter fout = new StreamWriter(new FileStream("mysubmission.csv", FileMode.Create))){ * bestNb.DumpLabelsToStream(fout); * } * SerializationChecks(); */ }