Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/15/11 13:34:38 (14 years ago)
Author:
mkommend
Message:

#1418: Finally added results from the grammar refactoring.

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  
    5656      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5757      var random = new MersenneTwister(31415);
     58      SymbolicExpressionTreeStringFormatter formatter = new SymbolicExpressionTreeStringFormatter();
    5859      IntValue maxTreeSize = new IntValue(MAX_TREE_LENGTH);
    5960      IntValue maxTreeHeigth = new IntValue(MAX_TREE_DEPTH);
     
    6162      IntValue maxArgs = new IntValue(3);
    6263      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);
    6465        Util.IsValid(tree);
    6566        trees.Add(tree);
    6667      }
    6768      Stopwatch stopwatch = new Stopwatch();
    68       stopwatch.Start();
    6969      int failedEvents = 0;
    7070      for (int g = 0; g < N_ITERATIONS; g++) {
     
    7272          if (random.NextDouble() < 0.5) {
    7373            // manipulate
     74            stopwatch.Start();
    7475            var selectedTree = (ISymbolicExpressionTree)trees.SelectRandom(random).Clone();
     76            var oldTree = (ISymbolicExpressionTree)selectedTree.Clone();
     77            var oldFormatedTree = formatter.Format(oldTree);
    7578            bool success = false;
    76             switch (random.Next(6)) {
     79            int sw = random.Next(6);
     80            switch (sw) {
    7781              case 0: success = ArgumentCreater.CreateNewArgument(random, selectedTree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); break;
    7882              case 1: success = ArgumentDeleter.DeleteArgument(random, selectedTree, 3, 3); break;
     
    8286              case 5: success = SubroutineDeleter.DeleteSubroutine(random, selectedTree, 3, 3); break;
    8387            }
     88            stopwatch.Stop();
    8489            if (!success) failedEvents++;
     90            var newFormatedTree = formatter.Format(selectedTree);
    8591            Util.IsValid(selectedTree);
    8692            newTrees.Add(selectedTree);
     
    98104        trees = newTrees;
    99105      }
    100       stopwatch.Stop();
    101106      var msPerOperation = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE / (double)N_ITERATIONS;
    102107      Console.WriteLine("AllArchitectureAlteringOperators: " + Environment.NewLine +
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ArgumentCreaterTest.cs

    r5549 r5686  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    24 using System.Collections.Generic;
    2525using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2626using HeuristicLab.Random;
     
    5757        ISymbolicExpressionTree tree;
    5858        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);
    6061        } while (!TreeHasAdfWithParameter(tree, 3));
    6162        var success = ArgumentCreater.CreateNewArgument(random, tree, 60000, 100, 3, 3);
     
    6667      // difficult to make sure that create argument operations succeed because trees are macro-expanded can potentially become very big
    6768      // => just test if only a small proportion fails
    68       Assert.IsTrue(failedOps < POPULATION_SIZE * 0.01 ); // only 1% may fail
     69      Assert.IsTrue(failedOps < POPULATION_SIZE * 0.01); // only 1% may fail
    6970      Console.WriteLine("ArgumentCreator: " + Environment.NewLine +
    7071        "Failed operations: " + failedOps * 100.0 / POPULATION_SIZE + " %" + Environment.NewLine +
     
    7778
    7879    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;
    8081      var firstAdf = tree.Root.GetSubTree(1);
    81       return firstAdf.Grammar.GetAllowedSymbols(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;
    8283    }
    8384  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ArgumentDeleterTest.cs

    r5549 r5686  
    5656        ISymbolicExpressionTree tree = null;
    5757        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);
    5960        } while (!TreeHasAdfWithArguments(tree));
    6061        var success = ArgumentDeleter.DeleteArgument(random, tree, 3, 3);
     
    7374      if (tree.Root.SubTrees.Count() != 2) return false;
    7475      var firstAdf = tree.Root.GetSubTree(1);
    75       return firstAdf.Grammar.GetAllowedSymbols(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;
    7677    }
    7778  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ArgumentDuplicaterTest.cs

    r5549 r5686  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    24 using System.Collections.Generic;
    2525using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2626using HeuristicLab.Random;
     
    5656        ISymbolicExpressionTree tree = null;
    5757        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));
    6061        var success = ArgumentDuplicater.DuplicateArgument(random, tree, 3, 3);
    6162        Assert.IsTrue(success);
     
    7475      if (tree.Root.SubTrees.Count() != 2) return false;
    7576      var firstAdf = tree.Root.GetSubTree(1);
    76       return firstAdf.Grammar.GetAllowedSymbols(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;
    7778    }
    7879  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ChangeNodeTypeManipulationTest.cs

    r5567 r5686  
    5555      int failedEvents = 0;
    5656      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);
    5858        string originalTree = formatter.Format(tree);
    5959        ChangeNodeTypeManipulation.ChangeNodeType(random, tree);
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Grammars.cs

    r5567 r5686  
    9494    }
    9595
    96     private class SimpleArithmeticGrammar : DefaultSymbolicExpressionGrammar {
     96    private class SimpleArithmeticGrammar : SymbolicExpressionGrammar {
    9797      protected SimpleArithmeticGrammar(SimpleArithmeticGrammar original, Cloner cloner) : base(original, cloner) { }
    9898      public SimpleArithmeticGrammar()
     
    119119
    120120        foreach (var funSymb in functionSymbols) {
    121           SetMinSubtreeCount(funSymb, 1);
    122           SetMaxSubtreeCount(funSymb, 3);
     121          SetSubtreeCount(funSymb, 1, 3);
    123122        }
    124         SetMinSubtreeCount(terminal, 0);
    125         SetMaxSubtreeCount(terminal, 0);
     123        SetSubtreeCount(terminal, 0, 0);
    126124
     125        SetSubtreeCount(StartSymbol, 1, 1);
    127126        // allow each symbol as child of the start symbol
    128127        foreach (var symb in allSymbols) {
    129           SetAllowedChild(StartSymbol, symb, 0);
     128          AddAllowedChildSymbol(StartSymbol, symb);
     129          AddAllowedChildSymbol(DefunSymbol, symb);
    130130        }
    131131
    132132        // 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          }
    138137        }
    139138      }
    140139    }
    141140
    142     public static ISymbolicExpressionTreeGrammar CreateSimpleArithmeticGrammar() {
    143       var g = new GlobalSymbolicExpressionGrammar(new SimpleArithmeticGrammar());
    144       g.MaxFunctionArguments = 0;
    145       g.MinFunctionArguments = 0;
    146       g.MaxFunctionDefinitions = 0;
    147       g.MinFunctionDefinitions = 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;
    148147      return g;
    149148    }
    150149
    151     public static ISymbolicExpressionTreeGrammar CreateArithmeticAndAdfGrammar() {
    152       var g = new GlobalSymbolicExpressionGrammar(new SimpleArithmeticGrammar());
    153       g.MaxFunctionArguments = 3;
    154       g.MinFunctionArguments = 0;
    155       g.MaxFunctionDefinitions = 3;
    156       g.MinFunctionDefinitions = 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;
    157156      return g;
    158157    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ProbabilisticTreeCreaterTest.cs

    r5549 r5686  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Diagnostics;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2526using HeuristicLab.Random;
    2627using Microsoft.VisualStudio.TestTools.UnitTesting;
    27 using System.Diagnostics;
    2828
    2929namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
     
    5656      stopwatch.Start();
    5757      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));
    5959      }
    6060      stopwatch.Stop();
     
    7272        Util.GetTerminalDistributionString(randomTrees) + Environment.NewLine
    7373        );
    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
    10475    }
    10576  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ReplaceBranchManipulationTest.cs

    r5549 r5686  
    5454      var random = new MersenneTwister(31415);
    5555      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);
    5758        string originalTree = formatter.Format(tree);
    5859        ReplaceBranchManipulation.ReplaceRandomBranch(random, tree, MAX_TREE_LENGTH, MAX_TREE_DEPTH);
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/SubroutineCreaterTest.cs

    r5549 r5686  
    2121
    2222using System;
    23 using System.Linq;
    2423using System.Collections.Generic;
    2524using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    5554      for (int i = 0; i < POPULATION_SIZE; i++) {
    5655        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);
    6057        var success = SubroutineCreater.CreateSubroutine(random, tree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
    6158        Assert.IsTrue(success);
     
    7067        );
    7168    }
    72 
    73     private bool OneMoreAdfAllowed(ISymbolicExpressionTree tree) {
    74       return tree.Length < 80 && tree.Root.SubTrees.Count() < 4;
    75     }
    7669  }
    7770}
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/SubroutineDeleterTest.cs

    r5549 r5686  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    24 using System.Collections.Generic;
    2525using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2626using HeuristicLab.Random;
     
    5656        ISymbolicExpressionTree tree = null;
    5757        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);
    5961        } while (!HasAtLeastOneAdf(tree));
    6062        var success = SubroutineDeleter.DeleteSubroutine(random, tree, 3, 3);
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/SubroutineDuplicaterTest.cs

    r5549 r5686  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    24 using System.Collections.Generic;
    2525using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2626using HeuristicLab.Random;
     
    5656        ISymbolicExpressionTree tree = null;
    5757        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);
    5961        } while (!HasOneAdf(tree));
    6062        var success = SubroutineDuplicater.DuplicateSubroutine(random, tree, 3, 3);
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/SubtreeCrossoverTest.cs

    r5549 r5686  
    5656
    5757      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);
    5961      }
    6062      Stopwatch stopwatch = new Stopwatch();
     
    8385        );
    8486
    85       Assert.IsTrue(Math.Round(1000.0 / (msPerCrossoverEvent)) > 2000); // must achieve more than 2000 x-overs/s
     87      Assert.IsTrue(Math.Round(1000.0 / (msPerCrossoverEvent)) > 2500); // must achieve more than 1500 x-overs/s
    8688    }
    8789  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Util.cs

    r5549 r5686  
    120120      foreach (var defunTreeNode in tree.Root.SubTrees.OfType<DefunTreeNode>()) {
    121121        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
    122134        var invoke = new InvokeFunction(defunTreeNode.FunctionName);
    123135        foreach (var otherRootNode in tree.Root.SubTrees) {
    124136          if (otherRootNode.Grammar.ContainsSymbol(invoke)) {
    125             Assert.IsTrue(otherRootNode.Grammar.GetMinSubtreeCount(invoke) == arity);
    126             Assert.IsTrue(otherRootNode.Grammar.GetMaxSubtreeCount(invoke) == arity);
     137            Assert.IsTrue(otherRootNode.Grammar.GetMinimumSubtreeCount(invoke) == arity);
     138            Assert.IsTrue(otherRootNode.Grammar.GetMaximumSubtreeCount(invoke) == arity);
    127139          }
    128140        }
     141
    129142      }
    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) {
    132144        Assert.AreNotSame(subtree.Grammar, tree.Root.Grammar);
     145        IsValid(subtree.Grammar);
     146      }
     147
     148      IsValid(tree.Root.Grammar);
    133149      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      }
    134161    }
    135162
     
    138165                            where symb.Name == treeNode.Symbol.Name
    139166                            select symb).SingleOrDefault();
    140       Assert.IsTrue(treeNode.SubTrees.Count() >= treeNode.Grammar.GetMinSubtreeCount(matchingSymbol));
    141       Assert.IsTrue(treeNode.SubTrees.Count() <= treeNode.Grammar.GetMaxSubtreeCount(matchingSymbol));
     167      Assert.IsTrue(treeNode.SubTrees.Count() >= treeNode.Grammar.GetMinimumSubtreeCount(matchingSymbol));
     168      Assert.IsTrue(treeNode.SubTrees.Count() <= treeNode.Grammar.GetMaximumSubtreeCount(matchingSymbol));
    142169      Assert.AreNotEqual(0.0, matchingSymbol.InitialFrequency); // check that no deactivated symbols occur in the tree
    143170      for (int i = 0; i < treeNode.SubTrees.Count(); i++) {
    144         Assert.IsTrue(treeNode.Grammar.GetAllowedSymbols(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));
    145172        IsValid(treeNode.GetSubTree(i));
    146173      }
Note: See TracChangeset for help on using the changeset viewer.