Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12025


Ignore:
Timestamp:
02/17/15 16:04:20 (10 years ago)
Author:
gkronber
Message:

#2283: unit test cases for symbolic regression

Location:
branches/HeuristicLab.Problems.GrammaticalOptimization/Test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Test/TestSymbRegInstances.cs

    r12014 r12025  
    3232
    3333    [TestMethod]
     34    [Timeout(1000 * 60 * 60 * 8)] // 8 hours
    3435    public void TestSequentialSolverForTower() {
    3536      var problem = new SymbolicRegressionProblem(new Random(), "Tower");
    3637      var random = new Random(31415);
    37       var solver = new SequentialSearch(problem, 30, random, 0, new GenericGrammarPolicy(problem, new UCB1TunedPolicy(), true));
     38      var solver = new SequentialSearch(problem, 50, random, 0, new GenericFunctionApproximationGrammarPolicy(problem, true));
    3839      solver.FoundNewBestSolution += (s, d) => {
    3940        Console.WriteLine("{0:F3} {1}", d, s);
    4041      };
    41       solver.Run(100);
     42      solver.Run(100000);
    4243    }
    4344
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Test/TestTunedSettings.cs

    r12014 r12025  
    1111using HeuristicLab.Algorithms.GrammaticalOptimization;
    1212using HeuristicLab.Common;
     13using HeuristicLab.Problems.GrammaticalOptimization.SymbReg;
    1314using Microsoft.VisualStudio.TestTools.UnitTesting;
    1415using RandomPolicy = HeuristicLab.Algorithms.Bandits.BanditPolicies.RandomPolicy;
     
    2829    }
    2930    [TestMethod]
     31    [Timeout(1000 * 60 * 60 * 12)] // 12 hours
    3032    // this configuration worked especially well in the experiments
    31     public void TestThresholdAscentArtificialAnt() {
     33    public void TestAllPoliciesArtificialAnt() {
    3234      CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
    3335
     
    4042        {
    4143         () => new RandomPolicy(),
    42           () => new ActiveLearningPolicy(), 
     44         () => new ActiveLearningPolicy(), 
    4345         () => new EpsGreedyPolicy(0.01, (aInfo)=> aInfo.MaxReward, "max"),
    4446         () => new EpsGreedyPolicy(0.05, (aInfo)=> aInfo.MaxReward, "max"),
     
    8183         () => new BoltzmannExplorationPolicy(200),
    8284         () => new BoltzmannExplorationPolicy(500),
    83           () => new ChernoffIntervalEstimationPolicy( 0.01),
    84           () => new ChernoffIntervalEstimationPolicy( 0.05),
    85           () => new ChernoffIntervalEstimationPolicy( 0.1),
    86           () => new ChernoffIntervalEstimationPolicy( 0.2),
     85         () => new ChernoffIntervalEstimationPolicy( 0.01),
     86         () => new ChernoffIntervalEstimationPolicy( 0.05),
     87         () => new ChernoffIntervalEstimationPolicy( 0.1),
     88         () => new ChernoffIntervalEstimationPolicy( 0.2),
    8789         () => new ThresholdAscentPolicy(5, 0.01),
    8890         () => new ThresholdAscentPolicy(5, 0.05),
     
    110112      var maxSizes = new int[] { 17 };  // necessary size for ant programm
    111113      int nReps = 20;
    112       int maxIterations = 20000;
     114      int maxIterations = 100000;
    113115      foreach (var instanceFactory in instanceFactories) {
    114116        var sumBestQ = 0.0;
     
    135137        // Assert.AreEqual(5461.7, sumItersToBest / (double)nReps, 1E-6);
    136138      }
    137 
     139    }
     140
     141
     142    [TestMethod]
     143    [Timeout(1000 * 60 * 60 * 12)] // 12 hours
     144    // this configuration worked especially well in the experiments
     145    public void TestPoly10WithOutConstantOpt() {
     146      CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
     147
     148      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
     149      {
     150        (randSeed) => (ISymbolicExpressionTreeProblem)new SymbolicRegressionPoly10Problem(),
     151      };
     152
     153      var maxSizes = new int[] { 23 }; 
     154      int nReps = 20;
     155      int maxIterations = 100000;
     156      foreach (var instanceFactory in instanceFactories) {
     157        var sumBestQ = 0.0;
     158        var sumItersToBest = 0;
     159        double fractionSolved = 0.0;
     160        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
     161          var prob = conf.Problem;
     162          var maxLen = conf.MaxSize;
     163          var rand = new Random(conf.RandSeed);
     164
     165          var solver = new SequentialSearch(prob, maxLen, rand, 0,
     166            new GenericFunctionApproximationGrammarPolicy(prob, true));
     167
     168          var problemName = prob.GetType().Name;
     169          double bestQ; int itersToBest;
     170          RunSolver(solver, problemName, string.Empty, 1.0, maxIterations, maxLen, out bestQ, out itersToBest);
     171          sumBestQ += bestQ;
     172          sumItersToBest += itersToBest;
     173          if (bestQ.IsAlmost(1.0)) fractionSolved += 1.0 / nReps;
     174        }
     175        // Assert.AreEqual(0.85, fractionSolved, 1E-6);
     176        // Assert.AreEqual(0.99438202247191, sumBestQ / nReps, 1E-6);
     177        // Assert.AreEqual(5461.7, sumItersToBest / (double)nReps, 1E-6);
     178      }
     179    }
     180
     181    [TestMethod]
     182    [Timeout(1000 * 60 * 60 * 12)] // 12 hours
     183    // this configuration worked especially well in the experiments
     184    public void TestPoly10WithConstantOpt() {
     185      CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
     186
     187      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
     188      {
     189        (randSeed) => (ISymbolicExpressionTreeProblem)new SymbolicRegressionProblem(new Random(randSeed), "Poly-10", true ),
     190      };
     191
     192      var maxSizes = new int[] { 23 }; 
     193      int nReps = 20;
     194      int maxIterations = 100000;
     195      foreach (var instanceFactory in instanceFactories) {
     196        var sumBestQ = 0.0;
     197        var sumItersToBest = 0;
     198        double fractionSolved = 0.0;
     199        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
     200          var prob = conf.Problem;
     201          var maxLen = conf.MaxSize;
     202          var rand = new Random(conf.RandSeed);
     203
     204          var solver = new SequentialSearch(prob, maxLen, rand, 0,
     205            new GenericFunctionApproximationGrammarPolicy(prob, true));
     206
     207          var problemName = prob.GetType().Name;
     208          double bestQ; int itersToBest;
     209          RunSolver(solver, problemName, string.Empty, 1.0, maxIterations, maxLen, out bestQ, out itersToBest);
     210          sumBestQ += bestQ;
     211          sumItersToBest += itersToBest;
     212          if (bestQ.IsAlmost(1.0)) fractionSolved += 1.0 / nReps;
     213        }
     214        // Assert.AreEqual(0.85, fractionSolved, 1E-6);
     215        // Assert.AreEqual(0.99438202247191, sumBestQ / nReps, 1E-6);
     216        // Assert.AreEqual(5461.7, sumItersToBest / (double)nReps, 1E-6);
     217      }
    138218    }
    139219
Note: See TracChangeset for help on using the changeset viewer.