Changeset 12025
- Timestamp:
- 02/17/15 16:04:20 (10 years ago)
- Location:
- branches/HeuristicLab.Problems.GrammaticalOptimization/Test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization/Test/TestSymbRegInstances.cs
r12014 r12025 32 32 33 33 [TestMethod] 34 [Timeout(1000 * 60 * 60 * 8)] // 8 hours 34 35 public void TestSequentialSolverForTower() { 35 36 var problem = new SymbolicRegressionProblem(new Random(), "Tower"); 36 37 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)); 38 39 solver.FoundNewBestSolution += (s, d) => { 39 40 Console.WriteLine("{0:F3} {1}", d, s); 40 41 }; 41 solver.Run(100 );42 solver.Run(100000); 42 43 } 43 44 -
branches/HeuristicLab.Problems.GrammaticalOptimization/Test/TestTunedSettings.cs
r12014 r12025 11 11 using HeuristicLab.Algorithms.GrammaticalOptimization; 12 12 using HeuristicLab.Common; 13 using HeuristicLab.Problems.GrammaticalOptimization.SymbReg; 13 14 using Microsoft.VisualStudio.TestTools.UnitTesting; 14 15 using RandomPolicy = HeuristicLab.Algorithms.Bandits.BanditPolicies.RandomPolicy; … … 28 29 } 29 30 [TestMethod] 31 [Timeout(1000 * 60 * 60 * 12)] // 12 hours 30 32 // this configuration worked especially well in the experiments 31 public void Test ThresholdAscentArtificialAnt() {33 public void TestAllPoliciesArtificialAnt() { 32 34 CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; 33 35 … … 40 42 { 41 43 () => new RandomPolicy(), 42 44 () => new ActiveLearningPolicy(), 43 45 () => new EpsGreedyPolicy(0.01, (aInfo)=> aInfo.MaxReward, "max"), 44 46 () => new EpsGreedyPolicy(0.05, (aInfo)=> aInfo.MaxReward, "max"), … … 81 83 () => new BoltzmannExplorationPolicy(200), 82 84 () => new BoltzmannExplorationPolicy(500), 83 84 85 86 85 () => new ChernoffIntervalEstimationPolicy( 0.01), 86 () => new ChernoffIntervalEstimationPolicy( 0.05), 87 () => new ChernoffIntervalEstimationPolicy( 0.1), 88 () => new ChernoffIntervalEstimationPolicy( 0.2), 87 89 () => new ThresholdAscentPolicy(5, 0.01), 88 90 () => new ThresholdAscentPolicy(5, 0.05), … … 110 112 var maxSizes = new int[] { 17 }; // necessary size for ant programm 111 113 int nReps = 20; 112 int maxIterations = 20000;114 int maxIterations = 100000; 113 115 foreach (var instanceFactory in instanceFactories) { 114 116 var sumBestQ = 0.0; … … 135 137 // Assert.AreEqual(5461.7, sumItersToBest / (double)nReps, 1E-6); 136 138 } 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 } 138 218 } 139 219
Note: See TracChangeset
for help on using the changeset viewer.