Changeset 5686 for branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ProbabilisticTreeCreaterTest.cs
- Timestamp:
- 03/15/11 13:34:38 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ProbabilisticTreeCreaterTest.cs
r5445 r5686 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Diagnostics; 24 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 25 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators; … … 30 31 [TestClass] 31 32 public class ProbabilisticTreeCreaterTest { 32 private const int POPULATION_SIZE = 1000 ;33 private const int POPULATION_SIZE = 10000; 33 34 private const int MAX_TREE_SIZE = 100; 34 35 private const int MAX_TREE_HEIGHT = 10; … … 53 54 var grammar = Grammars.CreateSimpleArithmeticGrammar(); 54 55 var random = new MersenneTwister(31415); 56 var stopwatch = new Stopwatch(); 57 stopwatch.Start(); 55 58 for (int i = 0; i < POPULATION_SIZE; i++) { 56 59 randomTrees.Add(ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 0, 0)); 57 60 } 61 stopwatch.Stop(); 58 62 59 63 foreach (var tree in randomTrees) { 60 64 Util.IsValid(tree); 61 65 } 66 double msPerRandomTreeCreation = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE; 67 62 68 Console.WriteLine("ProbabilisticTreeCreator: " + Environment.NewLine + 69 msPerRandomTreeCreation + " ms per random tree (~" + Math.Round(1000.0 / (msPerRandomTreeCreation)) + "random trees / s)" + Environment.NewLine + 63 70 Util.GetSizeDistributionString(randomTrees, 105, 5) + Environment.NewLine + 64 71 Util.GetFunctionDistributionString(randomTrees) + Environment.NewLine + … … 66 73 Util.GetTerminalDistributionString(randomTrees) + Environment.NewLine 67 74 ); 75 Assert.IsTrue(Math.Round(1000.0 / (msPerRandomTreeCreation)) > 2000); // must achieve more than 2000 random trees / s 68 76 } 69 77 … … 74 82 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 75 83 var random = new MersenneTwister(31415); 84 var stopwatch = new Stopwatch(); 85 stopwatch.Start(); 76 86 for (int i = 0; i < POPULATION_SIZE; i++) { 77 var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3); 87 randomTrees.Add(ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3)); 88 } 89 stopwatch.Stop(); 90 foreach (var tree in randomTrees) 78 91 Util.IsValid(tree); 79 randomTrees.Add(tree); 80 } 92 93 double msPerRandomTreeCreation = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE; 94 81 95 Console.WriteLine("ProbabilisticTreeCreator: " + Environment.NewLine + 96 msPerRandomTreeCreation + " ms per random tree (~" + Math.Round(1000.0 / (msPerRandomTreeCreation)) + "random trees / s)" + Environment.NewLine + 82 97 Util.GetSizeDistributionString(randomTrees, 105, 5) + Environment.NewLine + 83 98 Util.GetFunctionDistributionString(randomTrees) + Environment.NewLine + … … 85 100 Util.GetTerminalDistributionString(randomTrees) + Environment.NewLine 86 101 ); 102 103 Assert.IsTrue(Math.Round(1000.0 / (msPerRandomTreeCreation)) > 2000); // must achieve more than 2000 random trees / s 87 104 } 88 105 }
Note: See TracChangeset
for help on using the changeset viewer.