- Timestamp:
- 01/15/15 18:59:07 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization/Main/Program.cs
r11755 r11770 137 137 138 138 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 139 142 // TODO: unify MCTS, TD and ContextMCTS Solvers (stateInfos) 140 143 // TODO: test with eps-greedy using max instead of average as value (seems to work well for symb-reg! explore further!) … … 161 164 int iterations = 0; 162 165 var sw = new Stopwatch(); 163 double bestQuality = 0; 164 string bestSentence = ""; 166 165 167 var globalStatistics = new SentenceSetStatistics(); 166 168 var random = new Random(); … … 168 170 //var phraseLen = 3; 169 171 //var numPhrases = 5; 170 //var problem = new RoyalPhraseSequenceProblem(random, 1 0, 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) 177 179 // Ant 178 180 // good results e.g. with var alg = new MctsSampler(problem, 17, random, 1, (rand, numActions) => new ThresholdAscentPolicy(numActions, 500, 0.01)); 179 181 // 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(); 181 186 //var problem = new SymbolicRegressionProblem("Tower"); 182 187 //var problem = new PalindromeProblem(); … … 186 191 // symbreg length = 11 q = 0.824522210419616 187 192 //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)); 189 196 //var alg = new MctsQLearningSampler(problem, sentenceLen, random, 0, null); 190 197 //var alg = new MctsQLearningSampler(problem, 30, random, 0, new EpsGreedyPolicy(0.2)); … … 199 206 200 207 alg.FoundNewBestSolution += (sentence, quality) => { 201 bestQuality = quality;202 bestSentence = sentence;203 208 //Console.WriteLine("{0,4} {1,7} {2}", alg.treeDepth, alg.treeSize, globalStatistics); 204 209 //Console.ReadLine(); … … 208 213 globalStatistics.AddSentence(sentence, quality); 209 214 if (iterations % 100 == 0) { 210 //if (iterations % 1000 == 0) Console.Clear();215 if (iterations % 1000 == 0) Console.Clear(); 211 216 Console.SetCursorPosition(0, 0); 212 217 alg.PrintStats(); … … 226 231 sw.Stop(); 227 232 228 Console.WriteLine("{0,10} Best soultion: {1,10:F5} {2}", iterations, bestQuality, bestSentence); 233 Console.Clear(); 234 alg.PrintStats(); 235 Console.WriteLine(globalStatistics); 229 236 Console.WriteLine("{0:F2} sec {1,10:F1} sols/sec {2,10:F1} ns/sol", 230 237 sw.Elapsed.TotalSeconds,
Note: See TracChangeset
for help on using the changeset viewer.