Changeset 11973 for branches/HeuristicLab.Problems.GrammaticalOptimization
- Timestamp:
- 02/09/15 14:50:43 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization/Main/Program.cs
r11972 r11973 29 29 //RunGpDemo(); 30 30 //RunGridTest(); 31 RunGpGridTest(); 31 //RunGpGridTest(); 32 RunFunApproxTest(); 32 33 } 33 34 … … 306 307 307 308 309 private static void RunFunApproxTest() { 310 const int nReps = 20; 311 const int seed = 31415; 312 //const int maxIters = 50000; 313 var rand = new Random(seed); 314 var problemFactories = new Func<Tuple<int, int, ISymbolicExpressionTreeProblem>>[] 315 { 316 () => Tuple.Create(100000, 23, (ISymbolicExpressionTreeProblem)new SymbolicRegressionPoly10Problem()), 317 //() => Tuple.Create(100000, 17, (ISymbolicExpressionTreeProblem)new SantaFeAntProblem()), 318 //() => Tuple.Create(50000, 32,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()), 319 //() => Tuple.Create(50000, 64, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()), 320 //() => Tuple.Create(50000, 64,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()), 321 //() => Tuple.Create(50000, 128, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()), 322 //() => Tuple.Create(50000, 128,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()), 323 //() => Tuple.Create(50000, 256, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()), 324 //() => Tuple.Create(50000, 256,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()), 325 //() => new RoyalPairProblem(), 326 //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 0, 1, 0, true), 327 //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 0, 1, 0, false), 328 //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 50, 1, 0.8, false), 329 }; 330 331 // skip experiments that are already done 332 foreach (var problemFactory in problemFactories) { 333 for (int i = 0; i < nReps; i++) { 334 { 335 var solverSeed = rand.Next(); 336 var tupel = problemFactory(); 337 var maxIters = tupel.Item1; 338 var maxSize = tupel.Item2; 339 var prob = tupel.Item3; 340 341 var alg = new SequentialSearch(prob, maxSize, new Random(solverSeed), 0, 342 new HeuristicLab.Algorithms.Bandits.GrammarPolicies.GenericFunctionApproximationGrammarPolicy(prob, true)); 343 344 int iterations = 0; 345 var globalStatistics = new SentenceSetStatistics(prob.BestKnownQuality(maxSize)); 346 var algName = alg.GetType().Name; 347 var probName = prob.GetType().Name; 348 alg.SolutionEvaluated += (sentence, quality) => { 349 iterations++; 350 globalStatistics.AddSentence(sentence, quality); 351 352 if (iterations % 1000 == 0) { 353 Console.WriteLine("\"{0,25}\" {1} \"{2,25}\" {3}", algName, maxSize, probName, globalStatistics); 354 } 355 }; 356 357 alg.Run(maxIters); 358 359 } 360 361 } 362 } 363 } 364 308 365 private static void RunGpGridTest() { 309 366 const int nReps = 20;
Note: See TracChangeset
for help on using the changeset viewer.