- Timestamp:
- 02/02/15 20:41:11 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization/Main/Program.cs
r11847 r11865 25 25 26 26 //RunDemo(); 27 RunGpDemo();27 //RunGpDemo(); 28 28 // RunGridTest(); 29 RunGpGridTest(); 29 30 } 30 31 … … 174 175 175 176 private static void RunDemo() { 176 // TODO: implement bridge to HL-GP177 177 // TODO: unify MCTS, TD and ContextMCTS Solvers (stateInfos) 178 178 // TODO: test with eps-greedy using max instead of average as value (seems to work well for symb-reg! explore further!) 179 179 // TODO: separate value function from policy 180 // TODO: in contextual MCTS store a bandit info for each node in the _graph_ and also update all bandit infos of all parents181 // TODO: exhaustive search with priority list182 180 // TODO: warum funktioniert die alte Implementierung von GaussianThompson besser fÃŒr SantaFe als neue? Siehe Vergleich: alte vs. neue implementierung GaussianThompsonSampling 183 181 // TODO: why does GaussianThompsonSampling work so well with MCTS for the artificial ant problem? 184 182 // TODO: research thompson sampling for max bandit? 185 // TODO: ausfÃŒhrlicher test von strategien fÃŒr numCorrectPhrases-armed max bandit186 183 // TODO: verify TA implementation using example from the original paper 187 // TODO: separate policy from MCTS tree data structure to allow sharing of information over disconnected parts of the tree (semantic equivalence)188 184 // TODO: implement thompson sampling for gaussian mixture models 189 // TODO: implement inspection for MCTS (eventuell interactive command line fÃŒr statistiken aus dem baum anzeigen)190 // TODO: implement ACO-style bandit policy191 185 // TODO: gleichzeitige modellierung von transformierter zielvariable (y, 1/y, log(y), exp(y), sqrt(y), ...) 192 186 // TODO: vergleich bei complete-randomly möglichst kurze sÀtze generieren vs. einfach zufÀllig alternativen wÀhlen … … 299 293 300 294 public static void RunGpDemo() { 301 302 295 int iterations = 0; 296 const int seed = 31415; 303 297 const int maxIterations = 100000; 298 299 } 300 301 302 private static void RunGpGridTest() { 303 const int nReps = 20; 304 304 const int seed = 31415; 305 var globalStatistics = new SentenceSetStatistics(512); 306 307 var gp = new StandardGP(new HardPalindromeProblem(), new Random(seed)); 308 gp.FoundNewBestSolution += (sentence, quality) => { 309 Console.WriteLine("{0}", globalStatistics); 310 }; 305 const int maxIters = 100000; 306 var rand = new Random(seed); 307 var problemFactories = new Func<ISymbolicExpressionTreeProblem>[] 308 { 309 () => new SantaFeAntProblem(), 310 () => new SymbolicRegressionPoly10Problem(), 311 }; 312 foreach (var popSize in new int[] { 50, 100, 250, 500, 1000, 2500, 5000 }) { 313 foreach (var mutationRate in new double[] {/* 0.05, 0.10, */ 0.15, /* 0.25, 0.3 */ }) { 314 foreach (var maxSize in new int[] { 30, 50, 100 }) { 315 foreach (var problemFactory in problemFactories) 316 for (int i = 0; i < nReps; i++) { 317 var solverSeed = rand.Next(); 318 { 319 var prob = problemFactory(); 320 RunStandardGP(prob, solverSeed, maxIters, popSize, mutationRate, maxSize); 321 } 322 { 323 var prob = problemFactory(); 324 RunOSGP(prob, solverSeed, maxIters, popSize, mutationRate, maxSize); 325 } 326 } 327 } 328 } 329 } 330 } 331 332 private static void RunStandardGP(ISymbolicExpressionTreeProblem prob, int solverSeed, int maxIters, int popSize, double mutationRate, int maxSize) { 333 int iterations = 0; 334 var globalStatistics = new SentenceSetStatistics(prob.BestKnownQuality(maxSize)); 335 336 var gp = new StandardGP(prob, new Random(solverSeed)); 311 337 gp.SolutionEvaluated += (sentence, quality) => { 312 338 iterations++; … … 314 340 315 341 if (iterations % 10000 == 0) { 316 Console.WriteLine("{0}", globalStatistics); 317 } 318 }; 319 320 gp.PopulationSize = 1000; 321 gp.MaxSolutionSize = 31 + 2; 322 gp.MaxSolutionDepth = 20; 342 Console.WriteLine("\"{0,25}\" \"{1,25}\" {2}", gp, prob, globalStatistics); 343 } 344 }; 345 346 gp.PopulationSize = popSize; 347 gp.MutationRate = mutationRate; 348 gp.MaxSolutionSize = maxSize + 2; 349 gp.MaxSolutionDepth = maxSize + 2; 323 350 324 351 var sw = new Stopwatch(); 325 352 326 353 sw.Start(); 327 gp.Run(maxIter ations);354 gp.Run(maxIters); 328 355 sw.Stop(); 329 356 330 Console.WriteLine(globalStatistics); 331 Console.WriteLine("{0:F2} sec {1,10:F1} sols/sec {2,10:F1} ns/sol", 332 sw.Elapsed.TotalSeconds, 333 maxIterations / (double)sw.Elapsed.TotalSeconds, 334 (double)sw.ElapsedMilliseconds * 1000 / maxIterations); 357 Console.WriteLine("\"{0,25}\" \"{1,25}\" {2}", gp, prob, globalStatistics); 358 359 // Console.WriteLine("{0:F2} sec {1,10:F1} sols/sec {2,10:F1} ns/sol", 360 // sw.Elapsed.TotalSeconds, 361 // maxIters / (double)sw.Elapsed.TotalSeconds, 362 // (double)sw.ElapsedMilliseconds * 1000 / maxIters); 363 } 364 365 private static void RunOSGP(ISymbolicExpressionTreeProblem prob, int solverSeed, int maxIters, int popSize, double mutationRate, int maxSize) { 366 int iterations = 0; 367 var globalStatistics = new SentenceSetStatistics(prob.BestKnownQuality(maxSize)); 368 369 var gp = new OffspringSelectionGP(prob, new Random(solverSeed)); 370 gp.SolutionEvaluated += (sentence, quality) => { 371 iterations++; 372 globalStatistics.AddSentence(sentence, quality); 373 374 if (iterations % 10000 == 0) { 375 Console.WriteLine("\"{0,25}\" \"{1,25}\" {2}", gp, prob, globalStatistics); 376 } 377 }; 378 379 gp.PopulationSize = popSize; 380 gp.MutationRate = mutationRate; 381 gp.MaxSolutionSize = maxSize + 2; 382 gp.MaxSolutionDepth = maxSize + 2; 383 384 var sw = new Stopwatch(); 385 386 sw.Start(); 387 gp.Run(maxIters); 388 sw.Stop(); 389 390 Console.WriteLine("\"{0,25}\" \"{1,25}\" {2}", gp, prob, globalStatistics); 391 392 // Console.WriteLine("{0:F2} sec {1,10:F1} sols/sec {2,10:F1} ns/sol", 393 // sw.Elapsed.TotalSeconds, 394 // maxIters / (double)sw.Elapsed.TotalSeconds, 395 // (double)sw.ElapsedMilliseconds * 1000 / maxIters); 335 396 } 336 397 }
Note: See TracChangeset
for help on using the changeset viewer.