Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3307 for trunk/sources


Ignore:
Timestamp:
04/12/10 08:29:50 (15 years ago)
Author:
gkronber
Message:

Added ADF symbols to symbolic expression grammar for the test class for the subroutine creater. #290 (Implement ADFs)

File:
1 edited

Legend:

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

    r3297 r3307  
    88using System.Diagnostics;
    99using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureAlteringOperators;
     10using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.GeneralSymbols;
    1011
    1112namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     
    3839      var random = new MersenneTwister();
    3940      for (int i = 0; i < populationSize; i++) {
    40         randomTrees.Add(ProbabilisticTreeCreator.Create(random, grammar, 100, 10));
     41        var randTree = ProbabilisticTreeCreator.Create(random, grammar, 100, 10);
     42        Assert.IsTrue(grammar.IsValidExpression(randTree));
     43        randomTrees.Add(randTree);
    4144      }
    4245      var newPopulation = new List<SymbolicExpressionTree>();
     
    6265    private class TestGrammar : DefaultSymbolicExpressionGrammar {
    6366      public TestGrammar()
    64         : base(0, 0, 0, 0) {
     67        : base(0, 3, 0, 3) {
    6568        Initialize();
    6669      }
     
    7376        var terminal = new Terminal();
    7477
    75         var allSymbols = new List<Symbol>() { add, sub, mul, div, terminal };
     78        var defun = new Defun();
     79        var invoke = new InvokeFunction();
     80
     81        var allSymbols = new List<Symbol>() { add, sub, mul, div, terminal, invoke };
    7682        var functionSymbols = new List<Symbol>() { add, sub, mul, div };
    77         allSymbols.ForEach(s => AddAllowedSymbols(StartSymbol, 0, s));
    78 
     83        foreach (var symb in allSymbols) {
     84          AddAllowedSymbols(StartSymbol, 0, symb);
     85          AddAllowedSymbols(defun, 0, symb);
     86        }
     87        SetMinSubTreeCount(invoke, 0);
     88        SetMaxSubTreeCount(invoke, 3);
     89        for (int i = 0; i < 3; i++) {
     90          allSymbols.ForEach(s => AddAllowedSymbols(invoke, i, s));
     91        }
    7992        SetMinSubTreeCount(terminal, 0);
    8093        SetMaxSubTreeCount(terminal, 0);
Note: See TracChangeset for help on using the changeset viewer.