Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/12/15 21:23:01 (10 years ago)
Author:
gkronber
Message:

#2283: implemented test problems for MCTS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Main/Program.cs

    r11745 r11747  
    8888          Tuple.Create((IProblem)new SymbolicRegressionPoly10Problem(), 23),
    8989        })
    90         foreach (var randomTries in new int[] { 1, 10, /* 5, 100 /*, 500, 1000 */}) {
     90        foreach (var randomTries in new int[] { 0, 1, 10, /* 5, 100 /*, 500, 1000 */}) {
    9191          foreach (var policy in policies) {
    9292            var myRandomTries = randomTries;
     
    137137
    138138    private static void RunDemo() {
     139      // TODO: unify MCTS, TD and ContextMCTS Solvers (stateInfos)
    139140      // TODO: test with eps-greedy using max instead of average as value (seems to work well for symb-reg! explore further!)
    140141      // TODO: separate value function from policy
     
    165166      var random = new Random();
    166167
    167       var problem = new SymbolicRegressionPoly10Problem();   // good results e.g. 10 randomtries and EpsGreedyPolicy(0.2, (aInfo)=>aInfo.MaxReward)
     168      var phraseLen = 1;
     169      var sentenceLen = 25;
     170      var numPhrases = sentenceLen / phraseLen;
     171      var problem = new RoyalPhraseSequenceProblem(random, 10, numPhrases, phraseLen: 1, k: 1, correctReward: 1, incorrectReward: 0);
     172
     173      //var problem = new SymbolicRegressionPoly10Problem();   // good results e.g. 10 randomtries and EpsGreedyPolicy(0.2, (aInfo)=>aInfo.MaxReward)
    168174      // Ant
    169175      // good results e.g. with       var alg = new MctsSampler(problem, 17, random, 1, (rand, numActions) => new ThresholdAscentPolicy(numActions, 500, 0.01));
     
    175181      //var problem = new RoyalPairProblem();
    176182      //var problem = new EvenParityProblem();
    177       //var alg = new MctsSampler(problem, 23, random, 0, new GaussianThompsonSamplingPolicy(true));
    178       var alg = new MctsContextualSampler(problem, 23, random, 0);
    179       //var alg = new TemporalDifferenceTreeSearchSampler(problem, 17, random, 10, new EpsGreedyPolicy(0.1));
    180       //var alg = new ExhaustiveBreadthFirstSearch(problem, 17);
     183      // symbreg length = 11 q = 0.824522210419616
     184      var alg = new MctsSampler(problem, sentenceLen, random, 0, new BoltzmannExplorationPolicy(200));
     185      //var alg = new MctsQLearningSampler(problem, sentenceLen, random, 0, null);
     186      //var alg = new MctsQLearningSampler(problem, 30, random, 0, new EpsGreedyPolicy(0.2));
     187      //var alg = new MctsContextualSampler(problem, 23, random, 0); // must visit each canonical solution only once
     188      //var alg = new TemporalDifferenceTreeSearchSampler(problem, 30, random, 1);
     189      //var alg = new ExhaustiveBreadthFirstSearch(problem, 7);
    181190      //var alg = new AlternativesContextSampler(problem, random, 17, 4, (rand, numActions) => new RandomPolicy(rand, numActions));
    182191      //var alg = new ExhaustiveDepthFirstSearch(problem, 17);
    183192      // var alg = new AlternativesSampler(problem, 17);
    184193      // var alg = new RandomSearch(problem, random, 17);
    185       // var alg = new ExhaustiveRandomFirstSearch(problem, random, 17);
     194      //var alg = new ExhaustiveRandomFirstSearch(problem, random, 17);
    186195
    187196      alg.FoundNewBestSolution += (sentence, quality) => {
     
    199208          alg.PrintStats();
    200209        }
     210        //Console.WriteLine(sentence);
    201211
    202212        if (iterations % 10000 == 0) {
    203           //Console.WriteLine("{0,10} {1,10:F5} {2,10:F5} {3}", iterations, bestQuality, quality, sentence);
    204           //Console.WriteLine("{0,4} {1,7} {2}", alg.treeDepth, alg.treeSize, globalStatistics);
    205213          //Console.WriteLine("{0,4} {1,7} {2}", alg.treeDepth, alg.treeSize, globalStatistics);
    206214        }
Note: See TracChangeset for help on using the changeset viewer.