Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/15/15 18:59:07 (9 years ago)
Author:
gkronber
Message:

#2283: worked on generic sequential search alg with bandit policy as parameter

File:
1 edited

Legend:

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

    r11755 r11770  
    137137
    138138    private static void RunDemo() {
     139      // TODO: move problem instances into a separate folder
     140      // TODO: improve performance of SequentialSearch (memory allocations related to sequences)
     141      // TODO: implement bridge to HL-GP
    139142      // TODO: unify MCTS, TD and ContextMCTS Solvers (stateInfos)
    140143      // TODO: test with eps-greedy using max instead of average as value (seems to work well for symb-reg! explore further!)
     
    161164      int iterations = 0;
    162165      var sw = new Stopwatch();
    163       double bestQuality = 0;
    164       string bestSentence = "";
     166
    165167      var globalStatistics = new SentenceSetStatistics();
    166168      var random = new Random();
     
    168170      //var phraseLen = 3;
    169171      //var numPhrases = 5;
    170       //var problem = new RoyalPhraseSequenceProblem(random, 10, numPhrases, phraseLen: phraseLen, numCorrectPhrases: 1, correctReward: 1, incorrectReward: 0.0, phrasesAsSets: true);
    171 
    172       //var phraseLen = 4;
    173       //var numPhrases = 5;
    174       //var problem = new FindPhrasesProblem(random, 15, numPhrases, phraseLen, numOptimalPhrases: numPhrases, numDecoyPhrases: 500, correctReward: 1.0, decoyReward: 0.2, phrasesAsSets: true);
    175 
    176       var problem = new SymbolicRegressionPoly10Problem();   // good results e.g. 10 randomtries and EpsGreedyPolicy(0.2, (aInfo)=>aInfo.MaxReward)
     172      //var problem = new RoyalPhraseSequenceProblem(random, 15, numPhrases, phraseLen: phraseLen, numCorrectPhrases: 1, correctReward: 1, incorrectReward: 0.0, phrasesAsSets: true);
     173
     174      // var phraseLen = 2;
     175      // var numPhrases = 5;
     176      // var problem = new FindPhrasesProblem(random, 15, numPhrases, phraseLen, numOptimalPhrases: numPhrases, numDecoyPhrases: 0, correctReward: 1.0, decoyReward: 0.0, phrasesAsSets: true);
     177
     178      //var problem = new SymbolicRegressionPoly10Problem();   // good results e.g. 10 randomtries and EpsGreedyPolicy(0.2, (aInfo)=>aInfo.MaxReward)
    177179      // Ant
    178180      // good results e.g. with       var alg = new MctsSampler(problem, 17, random, 1, (rand, numActions) => new ThresholdAscentPolicy(numActions, 500, 0.01));
    179181      // GaussianModelWithUnknownVariance (and Q= 0.99-quantil) also works well for Ant
    180       //var problem = new SantaFeAntProblem();
     182      // very good results with:       var alg = new SequentialSearch(problem, 17, random, 0,
     183      // new HeuristicLab.Algorithms.Bandits.GrammarPolicies.GenericGrammarPolicy(problem, new UCB1TunedPolicy(), true));
     184
     185      var problem = new SantaFeAntProblem();
    181186      //var problem = new SymbolicRegressionProblem("Tower");
    182187      //var problem = new PalindromeProblem();
     
    186191      // symbreg length = 11 q = 0.824522210419616
    187192      //var alg = new MctsSampler(problem, 23, random, 0, new BoltzmannExplorationPolicy(100));
    188       var alg = new MctsSampler(problem, 23, random, 0, new EpsGreedyPolicy(0.1));
     193      //var alg = new MctsSampler(problem, 23, random, 0, new EpsGreedyPolicy(0.1));
     194      var alg = new SequentialSearch(problem, 10, random, 0,
     195        new HeuristicLab.Algorithms.Bandits.GrammarPolicies.GenericGrammarPolicy(problem, new GaussianThompsonSamplingPolicy(true), true));
    189196      //var alg = new MctsQLearningSampler(problem, sentenceLen, random, 0, null);
    190197      //var alg = new MctsQLearningSampler(problem, 30, random, 0, new EpsGreedyPolicy(0.2));
     
    199206
    200207      alg.FoundNewBestSolution += (sentence, quality) => {
    201         bestQuality = quality;
    202         bestSentence = sentence;
    203208        //Console.WriteLine("{0,4} {1,7} {2}", alg.treeDepth, alg.treeSize, globalStatistics);
    204209        //Console.ReadLine();
     
    208213        globalStatistics.AddSentence(sentence, quality);
    209214        if (iterations % 100 == 0) {
    210           //if (iterations % 1000 == 0) Console.Clear();
     215          if (iterations % 1000 == 0) Console.Clear();
    211216          Console.SetCursorPosition(0, 0);
    212217          alg.PrintStats();
     
    226231      sw.Stop();
    227232
    228       Console.WriteLine("{0,10} Best soultion: {1,10:F5} {2}", iterations, bestQuality, bestSentence);
     233      Console.Clear();
     234      alg.PrintStats();
     235      Console.WriteLine(globalStatistics);
    229236      Console.WriteLine("{0:F2} sec {1,10:F1} sols/sec {2,10:F1} ns/sol",
    230237        sw.Elapsed.TotalSeconds,
Note: See TracChangeset for help on using the changeset viewer.