Changeset 10277


Ignore:
Timestamp:
01/04/14 13:18:52 (8 years ago)
Author:
sawinkle
Message:

#2109: Replaced MinimumArity/MaximumArity with method call GetMinimumSubtreeCount()/GetMaximumSubtreeCount() in /Mappers/GenotypeToPhenotypeMapper.cs.
Now not the total arity (e.g. 1 to 255 for Addition) is taken, but the limited one (e.g. 1 to 1 for Addition).
As a result, the problem with the "broad" trees is solved.

Location:
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/BreathFirstMapper.cs

    r10229 r10277  
    9898
    9999          var newNode = GetNewChildNode(current.Item1, genotype, grammar, genotypeIndex, random);
    100           int arity = SampleArity(random, newNode, maxSubtreeCount - currSubtreeCount);
     100          int arity = SampleArity(random, newNode, maxSubtreeCount - currSubtreeCount, grammar);
    101101
    102102          if (arity < 0) {
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/DepthFirstMapper.cs

    r10276 r10277  
    101101
    102102        var newNode = GetNewChildNode(current.Item1, genotype, grammar, genotypeIndex, random);
    103         int arity = SampleArity(random, newNode, maxSubtreeCount - currSubtreeCount);
     103        int arity = SampleArity(random, newNode, maxSubtreeCount - currSubtreeCount, grammar);
    104104
    105105        if (arity < 0) {
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/GenotypeToPhenotypeMapper.cs

    r10228 r10277  
    109109    /// <param name="node">node, for which a random arity is determined</param>
    110110    /// <param name="maxAllowedArity">the resulting arity must not exceed this maximum arity</param>
     111    /// <param name="grammar">symbolic expression grammar to use</param>
    111112    /// <returns>random arity in the interval [minArity, maxArity] of the node or
    112113    ///          -1, if minArity exceeds maxAllowedArity</returns>
    113114    protected int SampleArity(IRandom random,
    114115                              ISymbolicExpressionTreeNode node,
    115                               int maxAllowedArity) {
    116       int minArity = node.Symbol.MinimumArity;
    117       int maxArity = node.Symbol.MaximumArity;
     116                              int maxAllowedArity,
     117                              ISymbolicExpressionGrammar grammar) {
     118
     119      int minArity = grammar.GetMinimumSubtreeCount(node.Symbol);
     120      int maxArity = grammar.GetMaximumSubtreeCount(node.Symbol);
    118121
    119122      if (maxAllowedArity < maxArity) {
Note: See TracChangeset for help on using the changeset viewer.