Changeset 5686 for branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests
- Timestamp:
- 03/15/11 13:34:38 (14 years ago)
- Location:
- branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/AllArchitectureAlteringOperatorsTest.cs
r5549 r5686 56 56 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 57 57 var random = new MersenneTwister(31415); 58 SymbolicExpressionTreeStringFormatter formatter = new SymbolicExpressionTreeStringFormatter(); 58 59 IntValue maxTreeSize = new IntValue(MAX_TREE_LENGTH); 59 60 IntValue maxTreeHeigth = new IntValue(MAX_TREE_DEPTH); … … 61 62 IntValue maxArgs = new IntValue(3); 62 63 for (int i = 0; i < POPULATION_SIZE; i++) { 63 var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH , 3, 3);64 var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH); 64 65 Util.IsValid(tree); 65 66 trees.Add(tree); 66 67 } 67 68 Stopwatch stopwatch = new Stopwatch(); 68 stopwatch.Start();69 69 int failedEvents = 0; 70 70 for (int g = 0; g < N_ITERATIONS; g++) { … … 72 72 if (random.NextDouble() < 0.5) { 73 73 // manipulate 74 stopwatch.Start(); 74 75 var selectedTree = (ISymbolicExpressionTree)trees.SelectRandom(random).Clone(); 76 var oldTree = (ISymbolicExpressionTree)selectedTree.Clone(); 77 var oldFormatedTree = formatter.Format(oldTree); 75 78 bool success = false; 76 switch (random.Next(6)) { 79 int sw = random.Next(6); 80 switch (sw) { 77 81 case 0: success = ArgumentCreater.CreateNewArgument(random, selectedTree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); break; 78 82 case 1: success = ArgumentDeleter.DeleteArgument(random, selectedTree, 3, 3); break; … … 82 86 case 5: success = SubroutineDeleter.DeleteSubroutine(random, selectedTree, 3, 3); break; 83 87 } 88 stopwatch.Stop(); 84 89 if (!success) failedEvents++; 90 var newFormatedTree = formatter.Format(selectedTree); 85 91 Util.IsValid(selectedTree); 86 92 newTrees.Add(selectedTree); … … 98 104 trees = newTrees; 99 105 } 100 stopwatch.Stop();101 106 var msPerOperation = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE / (double)N_ITERATIONS; 102 107 Console.WriteLine("AllArchitectureAlteringOperators: " + Environment.NewLine + -
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ArgumentCreaterTest.cs
r5549 r5686 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 using System.Collections.Generic;25 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 26 using HeuristicLab.Random; … … 57 57 ISymbolicExpressionTree tree; 58 58 do { 59 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 59 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH); 60 SubroutineCreater.CreateSubroutine(random, tree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 60 61 } while (!TreeHasAdfWithParameter(tree, 3)); 61 62 var success = ArgumentCreater.CreateNewArgument(random, tree, 60000, 100, 3, 3); … … 66 67 // difficult to make sure that create argument operations succeed because trees are macro-expanded can potentially become very big 67 68 // => just test if only a small proportion fails 68 Assert.IsTrue(failedOps < POPULATION_SIZE * 0.01 69 Assert.IsTrue(failedOps < POPULATION_SIZE * 0.01); // only 1% may fail 69 70 Console.WriteLine("ArgumentCreator: " + Environment.NewLine + 70 71 "Failed operations: " + failedOps * 100.0 / POPULATION_SIZE + " %" + Environment.NewLine + … … 77 78 78 79 private bool TreeHasAdfWithParameter(ISymbolicExpressionTree tree, int maxParameters) { 79 if (tree.Root.SubTrees.Count() != 2) return false;80 if (tree.Root.SubTrees.Count() != 2) return false; 80 81 var firstAdf = tree.Root.GetSubTree(1); 81 return firstAdf.Grammar.GetAllowed Symbols(firstAdf.Symbol, 0).Where(x => x is Argument).Count() < maxParameters;82 return firstAdf.Grammar.GetAllowedChildSymbols(firstAdf.Symbol, 0).Where(x => x is Argument).Count() < maxParameters; 82 83 } 83 84 } -
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ArgumentDeleterTest.cs
r5549 r5686 56 56 ISymbolicExpressionTree tree = null; 57 57 do { 58 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 58 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH); 59 SubroutineCreater.CreateSubroutine(random, tree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 59 60 } while (!TreeHasAdfWithArguments(tree)); 60 61 var success = ArgumentDeleter.DeleteArgument(random, tree, 3, 3); … … 73 74 if (tree.Root.SubTrees.Count() != 2) return false; 74 75 var firstAdf = tree.Root.GetSubTree(1); 75 return firstAdf.Grammar.GetAllowed Symbols(firstAdf.Symbol, 0).Where(x => x is Argument).Count() >= 2;76 return firstAdf.Grammar.GetAllowedChildSymbols(firstAdf.Symbol, 0).Where(x => x is Argument).Count() >= 2; 76 77 } 77 78 } -
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ArgumentDuplicaterTest.cs
r5549 r5686 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 using System.Collections.Generic;25 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 26 using HeuristicLab.Random; … … 56 56 ISymbolicExpressionTree tree = null; 57 57 do { 58 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 59 } while(!HasAdfWithArguments(tree)); 58 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH); 59 SubroutineCreater.CreateSubroutine(random, tree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 60 } while (!HasAdfWithArguments(tree)); 60 61 var success = ArgumentDuplicater.DuplicateArgument(random, tree, 3, 3); 61 62 Assert.IsTrue(success); … … 74 75 if (tree.Root.SubTrees.Count() != 2) return false; 75 76 var firstAdf = tree.Root.GetSubTree(1); 76 return firstAdf.Grammar.GetAllowed Symbols(firstAdf.Symbol, 0).Where(x => x is Argument).Count() == 1;77 return firstAdf.Grammar.GetAllowedChildSymbols(firstAdf.Symbol, 0).Where(x => x is Argument).Count() == 1; 77 78 } 78 79 } -
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ChangeNodeTypeManipulationTest.cs
r5567 r5686 55 55 int failedEvents = 0; 56 56 for (int i = 0; i < POPULATION_SIZE; i++) { 57 var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH , 3, 3);57 var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH); 58 58 string originalTree = formatter.Format(tree); 59 59 ChangeNodeTypeManipulation.ChangeNodeType(random, tree); -
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Grammars.cs
r5567 r5686 94 94 } 95 95 96 private class SimpleArithmeticGrammar : DefaultSymbolicExpressionGrammar {96 private class SimpleArithmeticGrammar : SymbolicExpressionGrammar { 97 97 protected SimpleArithmeticGrammar(SimpleArithmeticGrammar original, Cloner cloner) : base(original, cloner) { } 98 98 public SimpleArithmeticGrammar() … … 119 119 120 120 foreach (var funSymb in functionSymbols) { 121 SetMinSubtreeCount(funSymb, 1); 122 SetMaxSubtreeCount(funSymb, 3); 121 SetSubtreeCount(funSymb, 1, 3); 123 122 } 124 SetMinSubtreeCount(terminal, 0); 125 SetMaxSubtreeCount(terminal, 0); 123 SetSubtreeCount(terminal, 0, 0); 126 124 125 SetSubtreeCount(StartSymbol, 1, 1); 127 126 // allow each symbol as child of the start symbol 128 127 foreach (var symb in allSymbols) { 129 SetAllowedChild(StartSymbol, symb, 0); 128 AddAllowedChildSymbol(StartSymbol, symb); 129 AddAllowedChildSymbol(DefunSymbol, symb); 130 130 } 131 131 132 132 // allow each symbol as child of every other symbol (except for terminals that have maxSubtreeCount == 0) 133 foreach (var parent in allSymbols) { 134 for (int i = 0; i < GetMaxSubtreeCount(parent); i++) 135 foreach (var child in allSymbols) { 136 SetAllowedChild(parent, child, i); 137 } 133 foreach (var parent in functionSymbols) { 134 foreach (var child in allSymbols) { 135 AddAllowedChildSymbol(parent, child); 136 } 138 137 } 139 138 } 140 139 } 141 140 142 public static ISymbolicExpression TreeGrammar CreateSimpleArithmeticGrammar() {143 var g = new GlobalSymbolicExpressionGrammar(new SimpleArithmeticGrammar());144 g.Max FunctionArguments = 0;145 g.Min FunctionArguments = 0;146 g.Max FunctionDefinitions = 0;147 g.Min FunctionDefinitions = 0;141 public static ISymbolicExpressionGrammar CreateSimpleArithmeticGrammar() { 142 var g = new SimpleArithmeticGrammar(); 143 g.MaximumFunctionArguments = 0; 144 g.MinimumFunctionArguments = 0; 145 g.MaximumFunctionDefinitions = 0; 146 g.MinimumFunctionDefinitions = 0; 148 147 return g; 149 148 } 150 149 151 public static ISymbolicExpression TreeGrammar CreateArithmeticAndAdfGrammar() {152 var g = new GlobalSymbolicExpressionGrammar(new SimpleArithmeticGrammar());153 g.Max FunctionArguments = 3;154 g.Min FunctionArguments = 0;155 g.Max FunctionDefinitions = 3;156 g.Min FunctionDefinitions = 0;150 public static ISymbolicExpressionGrammar CreateArithmeticAndAdfGrammar() { 151 var g = new SimpleArithmeticGrammar(); 152 g.MaximumFunctionArguments = 3; 153 g.MinimumFunctionArguments = 0; 154 g.MaximumFunctionDefinitions = 3; 155 g.MinimumFunctionDefinitions = 0; 157 156 return g; 158 157 } -
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 } -
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ReplaceBranchManipulationTest.cs
r5549 r5686 54 54 var random = new MersenneTwister(31415); 55 55 for (int i = 0; i < POPULATION_SIZE; i++) { 56 var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 56 var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH); 57 SubroutineCreater.CreateSubroutine(random, tree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 57 58 string originalTree = formatter.Format(tree); 58 59 ReplaceBranchManipulation.ReplaceRandomBranch(random, tree, MAX_TREE_LENGTH, MAX_TREE_DEPTH); -
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/SubroutineCreaterTest.cs
r5549 r5686 21 21 22 22 using System; 23 using System.Linq;24 23 using System.Collections.Generic; 25 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 55 54 for (int i = 0; i < POPULATION_SIZE; i++) { 56 55 ISymbolicExpressionTree tree = null; 57 do { 58 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 59 } while ( !OneMoreAdfAllowed(tree)); 56 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH - 10, MAX_TREE_DEPTH); 60 57 var success = SubroutineCreater.CreateSubroutine(random, tree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 61 58 Assert.IsTrue(success); … … 70 67 ); 71 68 } 72 73 private bool OneMoreAdfAllowed(ISymbolicExpressionTree tree) {74 return tree.Length < 80 && tree.Root.SubTrees.Count() < 4;75 }76 69 } 77 70 } -
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/SubroutineDeleterTest.cs
r5549 r5686 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 using System.Collections.Generic;25 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 26 using HeuristicLab.Random; … … 56 56 ISymbolicExpressionTree tree = null; 57 57 do { 58 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 58 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH); 59 SubroutineCreater.CreateSubroutine(random, tree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 60 SubroutineCreater.CreateSubroutine(random, tree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 59 61 } while (!HasAtLeastOneAdf(tree)); 60 62 var success = SubroutineDeleter.DeleteSubroutine(random, tree, 3, 3); -
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/SubroutineDuplicaterTest.cs
r5549 r5686 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 using System.Collections.Generic;25 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 26 using HeuristicLab.Random; … … 56 56 ISymbolicExpressionTree tree = null; 57 57 do { 58 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 58 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH); 59 for (int j = random.Next(3); j < 3; j++) 60 SubroutineCreater.CreateSubroutine(random, tree, 100, 10, 3, 3); 59 61 } while (!HasOneAdf(tree)); 60 62 var success = SubroutineDuplicater.DuplicateSubroutine(random, tree, 3, 3); -
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/SubtreeCrossoverTest.cs
r5549 r5686 56 56 57 57 for (int i = 0; i < POPULATION_SIZE; i++) { 58 trees.Add(ProbabilisticTreeCreator.Create(random, grammar, 100, 10, 3, 3)); 58 trees.Add(ProbabilisticTreeCreator.Create(random, grammar, 100, 10)); 59 for (int j = random.Next(3); j < 3; j++) 60 SubroutineCreater.CreateSubroutine(random, trees[i], 100, 10, 3, 3); 59 61 } 60 62 Stopwatch stopwatch = new Stopwatch(); … … 83 85 ); 84 86 85 Assert.IsTrue(Math.Round(1000.0 / (msPerCrossoverEvent)) > 2 000); // must achieve more than 2000 x-overs/s87 Assert.IsTrue(Math.Round(1000.0 / (msPerCrossoverEvent)) > 2500); // must achieve more than 1500 x-overs/s 86 88 } 87 89 } -
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Util.cs
r5549 r5686 120 120 foreach (var defunTreeNode in tree.Root.SubTrees.OfType<DefunTreeNode>()) { 121 121 int arity = defunTreeNode.NumberOfArguments; 122 123 foreach (var argTreenode in defunTreeNode.IterateNodesPrefix().OfType<ArgumentTreeNode>()) { 124 Assert.IsTrue(argTreenode.SubtreesCount == 0); 125 Assert.IsTrue(((Argument)argTreenode.Symbol).ArgumentIndex < arity); 126 } 127 128 foreach (var argSymbol in Enumerable.Range(0, defunTreeNode.NumberOfArguments).Select(x => new Argument(x))) { 129 Assert.IsTrue(defunTreeNode.Grammar.ContainsSymbol(argSymbol)); 130 Assert.IsTrue(defunTreeNode.Grammar.GetMaximumSubtreeCount(argSymbol) == 0); 131 Assert.IsTrue(defunTreeNode.Grammar.GetMinimumSubtreeCount(argSymbol) == 0); 132 } 133 122 134 var invoke = new InvokeFunction(defunTreeNode.FunctionName); 123 135 foreach (var otherRootNode in tree.Root.SubTrees) { 124 136 if (otherRootNode.Grammar.ContainsSymbol(invoke)) { 125 Assert.IsTrue(otherRootNode.Grammar.GetMin SubtreeCount(invoke) == arity);126 Assert.IsTrue(otherRootNode.Grammar.GetMax SubtreeCount(invoke) == arity);137 Assert.IsTrue(otherRootNode.Grammar.GetMinimumSubtreeCount(invoke) == arity); 138 Assert.IsTrue(otherRootNode.Grammar.GetMaximumSubtreeCount(invoke) == arity); 127 139 } 128 140 } 141 129 142 } 130 //Assert.AreEqual(tree.Root.Symbol, tree.Root.Grammar.StartSymbol); 131 foreach (var subtree in tree.Root.SubTrees) 143 foreach (var subtree in tree.Root.SubTrees) { 132 144 Assert.AreNotSame(subtree.Grammar, tree.Root.Grammar); 145 IsValid(subtree.Grammar); 146 } 147 148 IsValid(tree.Root.Grammar); 133 149 IsValid(tree.Root); 150 } 151 152 public static void IsValid(ISymbolicExpressionTreeGrammar grammar) { 153 Assert.IsTrue(grammar.Symbols.Count() == grammar.Symbols.Distinct().Count()); 154 foreach (ISymbol symbol in grammar.Symbols) { 155 Assert.IsTrue(grammar.GetMinimumSubtreeCount(symbol) <= grammar.GetMaximumExpressionLength(symbol)); 156 Assert.IsTrue(grammar.GetAllowedChildSymbols(symbol).Count() == grammar.GetAllowedChildSymbols(symbol).Distinct().Count()); 157 for (int i = 0; i < grammar.GetMaximumSubtreeCount(symbol); i++) { 158 Assert.IsTrue(grammar.GetAllowedChildSymbols(symbol, i).Count() == grammar.GetAllowedChildSymbols(symbol, i).Distinct().Count()); 159 } 160 } 134 161 } 135 162 … … 138 165 where symb.Name == treeNode.Symbol.Name 139 166 select symb).SingleOrDefault(); 140 Assert.IsTrue(treeNode.SubTrees.Count() >= treeNode.Grammar.GetMin SubtreeCount(matchingSymbol));141 Assert.IsTrue(treeNode.SubTrees.Count() <= treeNode.Grammar.GetMax SubtreeCount(matchingSymbol));167 Assert.IsTrue(treeNode.SubTrees.Count() >= treeNode.Grammar.GetMinimumSubtreeCount(matchingSymbol)); 168 Assert.IsTrue(treeNode.SubTrees.Count() <= treeNode.Grammar.GetMaximumSubtreeCount(matchingSymbol)); 142 169 Assert.AreNotEqual(0.0, matchingSymbol.InitialFrequency); // check that no deactivated symbols occur in the tree 143 170 for (int i = 0; i < treeNode.SubTrees.Count(); i++) { 144 Assert.IsTrue(treeNode.Grammar.GetAllowed Symbols(treeNode.Symbol, i).Select(x => x.Name).Contains(treeNode.GetSubTree(i).Symbol.Name));171 Assert.IsTrue(treeNode.Grammar.GetAllowedChildSymbols(treeNode.Symbol, i).Select(x => x.Name).Contains(treeNode.GetSubTree(i).Symbol.Name)); 145 172 IsValid(treeNode.GetSubTree(i)); 146 173 }
Note: See TracChangeset
for help on using the changeset viewer.