Changeset 5686 for branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ProbabilisticTreeCreaterTest.cs
- Timestamp:
- 03/15/11 13:34:38 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ProbabilisticTreeCreaterTest.cs
r5549 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.Random; 26 27 using Microsoft.VisualStudio.TestTools.UnitTesting; 27 using System.Diagnostics;28 28 29 29 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests { … … 56 56 stopwatch.Start(); 57 57 for (int i = 0; i < POPULATION_SIZE; i++) { 58 randomTrees.Add(ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH , 0, 0));58 randomTrees.Add(ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH)); 59 59 } 60 60 stopwatch.Stop(); … … 72 72 Util.GetTerminalDistributionString(randomTrees) + Environment.NewLine 73 73 ); 74 Assert.IsTrue(Math.Round(1000.0 / (msPerRandomTreeCreation)) > 2000); // must achieve more than 2000 random trees / s 75 } 76 77 78 [TestMethod()] 79 public void ProbabilisticTreeCreaterWithAdfDistributionsTest() { 80 var randomTrees = new List<ISymbolicExpressionTree>(); 81 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 82 var random = new MersenneTwister(31415); 83 var stopwatch = new Stopwatch(); 84 stopwatch.Start(); 85 for (int i = 0; i < POPULATION_SIZE; i++) { 86 var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 87 randomTrees.Add(tree); 88 } 89 stopwatch.Stop(); 90 foreach (var tree in randomTrees) 91 Util.IsValid(tree); 92 93 double msPerRandomTreeCreation = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE; 94 95 Console.WriteLine("ProbabilisticTreeCreator: " + Environment.NewLine + 96 msPerRandomTreeCreation + " ms per random tree (~" + Math.Round(1000.0 / (msPerRandomTreeCreation)) + "random trees / s)" + Environment.NewLine + 97 Util.GetSizeDistributionString(randomTrees, 105, 5) + Environment.NewLine + 98 Util.GetFunctionDistributionString(randomTrees) + Environment.NewLine + 99 Util.GetNumberOfSubTreesDistributionString(randomTrees) + Environment.NewLine + 100 Util.GetTerminalDistributionString(randomTrees) + Environment.NewLine 101 ); 102 103 Assert.IsTrue(Math.Round(1000.0 / (msPerRandomTreeCreation)) > 2000); // must achieve more than 2000 random trees / s 74 Assert.IsTrue(Math.Round(1000.0 / (msPerRandomTreeCreation)) > 500); // must achieve more than 500 random trees / s 104 75 } 105 76 }
Note: See TracChangeset
for help on using the changeset viewer.