Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/26/10 16:18:45 (14 years ago)
Author:
gkronber
Message:

Fixed bugs in SubtreeCrossover, ArgumentCreater and ArgumentDuplicater and updated unit tests for symbolic expression tree operators. #1103

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/Grammars.cs

    r4068 r4106  
    2626namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
    2727  public static class Grammars {
    28     private class Addition : Symbol { }
    29     private class Subtraction : Symbol { }
    30     private class Multiplication : Symbol { }
    31     private class Division : Symbol { }
    32     private class Terminal : Symbol { }
     28    private class Addition : Symbol { public Addition() : base("Addition", "") { } }
     29    private class Subtraction : Symbol { public Subtraction() : base("Subtraction", "") { } }
     30    private class Multiplication : Symbol { public Multiplication() : base("Multiplication", "") { } }
     31    private class Division : Symbol { public Division() : base("Division", "") { } }
     32    private class Terminal : Symbol { public Terminal() : base("Terminal", "") { } }
    3333
    3434    private class SimpleArithmeticGrammar : DefaultSymbolicExpressionGrammar {
     
    8989      return g;
    9090    }
    91 
    92     public static void HasValidAdfGrammars(SymbolicExpressionTree tree) {
    93       //Assert.AreEqual(tree.Root.Grammar.Symbols.Count(), 8);
    94       //Assert.AreEqual(tree.Root.GetAllowedSymbols(0).Count(), 1); // only the start symbol is allowed
    95       //// we allow 3 ADF branches
    96       //Assert.AreEqual(tree.Root.GetAllowedSymbols(1).Count(), 1); // only the defun branch is allowed
    97       //Assert.AreEqual(tree.Root.GetAllowedSymbols(2).Count(), 1); // only the defun symbol is allowed
    98       //Assert.AreEqual(tree.Root.GetAllowedSymbols(3).Count(), 1); // only the defun symbol is allowed
    99       //foreach (var subtree in tree.Root.SubTrees) {
    100       //  // check consistency of each sub-tree grammar independently
    101       //  var allowedSymbols = subtree.GetAllowedSymbols(0);
    102       //  int numberOfAllowedSymbols = allowedSymbols.Count();
    103       //  foreach (var parent in allowedSymbols) {
    104       //    for (int argIndex = 0; argIndex < subtree.Grammar.GetMaxSubtreeCount(parent); argIndex++) {
    105       //      var allowedChildren = from child in subtree.Grammar.Symbols
    106       //                            where subtree.Grammar.IsAllowedChild(parent, child, argIndex)
    107       //                            select child;
    108       //      Assert.AreEqual(numberOfAllowedSymbols, allowedChildren.Count());
    109       //    }
    110       //  }
    111       //}
    112     }
    113 
    11491  }
    11592}
Note: See TracChangeset for help on using the changeset viewer.