Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/06/15 18:20:35 (10 years ago)
Author:
gkronber
Message:

#2283: more unit tests to generate data for eurocast

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/Test/RunMctsExperiments.cs

    r12370 r12386  
    11using System;
    2 using System.Collections;
    32using System.Collections.Generic;
    43using System.Globalization;
     
    76using HeuristicLab.Algorithms.Bandits.GrammarPolicies;
    87using HeuristicLab.Algorithms.Bandits.Models;
    9 using HeuristicLab.Algorithms.GeneticProgramming;
    108using HeuristicLab.Algorithms.GrammaticalOptimization;
    11 using HeuristicLab.Problems.GrammaticalOptimization;
    12 using HeuristicLab.Problems.GrammaticalOptimization.SymbReg;
    139using Microsoft.VisualStudio.TestTools.UnitTesting;
    1410using RandomPolicy = HeuristicLab.Algorithms.Bandits.BanditPolicies.RandomPolicy;
     
    144140      }
    145141    }
    146 
    147     #endregion
    148 
     142    #endregion
     143
     144    #region hardpalindrome
     145    [TestMethod]
     146    [Timeout(1000 * 60 * 60 * 120)] // 120 hours
     147    public void RunMctsPalindromeProblem() {
     148      CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
     149
     150      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
     151      {
     152        (randSeed) => (ISymbolicExpressionTreeProblem) new HardPalindromeProblem(),
     153      };
     154
     155      var maxSizes = new int[] { 10, 20, 30, 40, 50 };
     156      int nReps = 30;
     157      int maxIterations = 100000;
     158      foreach (var instanceFactory in instanceFactories) {
     159        foreach (var policyFactory in policyFactories) {
     160          foreach (var conf in GenerateConfigurations(instanceFactory, policyFactory, nReps, maxSizes)) {
     161            RunMctsForProblem(conf.RandSeed, conf.Problem, conf.Policy, maxIterations, conf.MaxSize);
     162          }
     163        }
     164      }
     165    }
     166    #endregion
     167
     168    #region royalpair
     169    [TestMethod]
     170    [Timeout(1000 * 60 * 60 * 120)] // 120 hours
     171    public void RunMctsRoyalPairProblem() {
     172      CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
     173
     174      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
     175      {
     176        (randSeed) => (ISymbolicExpressionTreeProblem) new RoyalPairProblem(2),
     177        (randSeed) => (ISymbolicExpressionTreeProblem) new RoyalPairProblem(4),
     178        (randSeed) => (ISymbolicExpressionTreeProblem) new RoyalPairProblem(8),
     179        (randSeed) => (ISymbolicExpressionTreeProblem) new RoyalPairProblem(16),
     180      };
     181
     182      var maxSizes = new int[] { 10, 20, 30, 40, 50 };
     183      int nReps = 30;
     184      int maxIterations = 100000;
     185      foreach (var instanceFactory in instanceFactories) {
     186        foreach (var policyFactory in policyFactories) {
     187          foreach (var conf in GenerateConfigurations(instanceFactory, policyFactory, nReps, maxSizes)) {
     188            RunMctsForProblem(conf.RandSeed, conf.Problem, conf.Policy, maxIterations, conf.MaxSize);
     189          }
     190        }
     191      }
     192    }
     193    #endregion
     194
     195    #region royalseq
     196    [TestMethod]
     197    [Timeout(1000 * 60 * 60 * 120)] // 120 hours
     198    public void RunMctsRoyalSequenceProblem() {
     199      CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
     200
     201      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
     202      {
     203        (randSeed) => (ISymbolicExpressionTreeProblem) new RoyalSequenceProblem(new Random(randSeed), 3, 50),
     204        (randSeed) => (ISymbolicExpressionTreeProblem) new RoyalSequenceProblem(new Random(randSeed), 5, 50),
     205        (randSeed) => (ISymbolicExpressionTreeProblem) new RoyalSequenceProblem(new Random(randSeed), 10, 50),
     206        (randSeed) => (ISymbolicExpressionTreeProblem) new RoyalSequenceProblem(new Random(randSeed), 20, 50),
     207      };
     208
     209      var maxSizes = new int[] { 10, 20, 30, 40, 50 };
     210      int nReps = 30;
     211      int maxIterations = 100000;
     212      foreach (var instanceFactory in instanceFactories) {
     213        foreach (var policyFactory in policyFactories) {
     214          foreach (var conf in GenerateConfigurations(instanceFactory, policyFactory, nReps, maxSizes)) {
     215            RunMctsForProblem(conf.RandSeed, conf.Problem, conf.Policy, maxIterations, conf.MaxSize);
     216          }
     217        }
     218      }
     219    }
     220    #endregion
     221
     222    #region royaltree
     223    [TestMethod]
     224    [Timeout(1000 * 60 * 60 * 120)] // 120 hours
     225    public void RunMctsRoyalTreeProblem() {
     226      CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
     227
     228      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
     229      {
     230        (randSeed) => (ISymbolicExpressionTreeProblem) new RoyalTreeProblem(3),
     231        (randSeed) => (ISymbolicExpressionTreeProblem) new RoyalTreeProblem(4),
     232        // (randSeed) => (ISymbolicExpressionTreeProblem) new RoyalTreeProblem(5),
     233        // (randSeed) => (ISymbolicExpressionTreeProblem) new RoyalTreeProblem(6),
     234      };
     235
     236      var maxSizes = new int[] { 30, 100, 200 };
     237      int nReps = 30;
     238      int maxIterations = 100000;
     239      foreach (var instanceFactory in instanceFactories) {
     240        foreach (var policyFactory in policyFactories) {
     241          foreach (var conf in GenerateConfigurations(instanceFactory, policyFactory, nReps, maxSizes)) {
     242            RunMctsForProblem(conf.RandSeed, conf.Problem, conf.Policy, maxIterations, conf.MaxSize);
     243          }
     244        }
     245      }
     246    }
     247    #endregion
     248
     249    #region findphrases
     250    [TestMethod]
     251    [Timeout(1000 * 60 * 60 * 120)] // 120 hours
     252    public void RunMctsFindPhrasesProblem() {
     253      CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
     254
     255      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
     256      {
     257        (randSeed) => (ISymbolicExpressionTreeProblem) new FindPhrasesProblem(new Random(randSeed), 10, 10, 3, 10, 0, 1.0, 0.0, true),
     258      };
     259
     260      var maxSizes = new int[] { 9, 12, 15, 21, 30 };
     261      int nReps = 30;
     262      int maxIterations = 100000;
     263      foreach (var instanceFactory in instanceFactories) {
     264        foreach (var policyFactory in policyFactories) {
     265          foreach (var conf in GenerateConfigurations(instanceFactory, policyFactory, nReps, maxSizes)) {
     266            RunMctsForProblem(conf.RandSeed, conf.Problem, conf.Policy, maxIterations, conf.MaxSize);
     267          }
     268        }
     269      }
     270    }
     271    #endregion
     272   
    149273    #region helpers
    150274    private IEnumerable<Configuration> GenerateConfigurations(
Note: See TracChangeset for help on using the changeset viewer.