Free cookie consent management tool by TermsFeed Policy Generator

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

#1418: Finally added results from the grammar refactoring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.