Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/21/13 11:29:55 (11 years ago)
Author:
sawinkle
Message:

#2109:

  • For each newly created node, ResetLocalParameters() has to be called, if possible. Otherwise 'Variable' symbols won't be initialized correctly. (E.g. internal ValueName is null and causes exceptions.)
  • Method MapDepthFirstRecursively() of DepthFirstMapper.cs checks subtree boundaries by using the MinimumArity instead of the MaximumArity. Otherwise e.g. adding the 'Addition' symbol will cause very short trees, because this symbol has got a MaximumArity of 255! This would cause, that the tree is immediately full, after insertion of one 'Addition' symbol, if the genotype length is e.g. just 100.
  • Several bug fixes.
  • Unresolved issues:
    • Changes in the selected grammar are not taken into account during a run (e.g. 'Addition' symbols will be inserted into the tree, although its checkbox was unchecked previously).
    • Exception, if a division by zero is tried.
    • Wrapping mechanism.
File:
1 edited

Legend:

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

    r10068 r10075  
    5252    protected ISymbolicExpressionTreeNode GetRandomTerminalNode(ISymbolicExpressionTreeNode parentNode,
    5353                                                              ISymbolicExpressionGrammar grammar) {
    54       var possibleSymbolsList = from s in grammar.GetAllowedChildSymbols(parentNode.Symbol)
    55                                 where s.MaximumArity == 0
    56                                 where s.MinimumArity == 0
    57                                 select s;
    58       // TODO: Check, if symbol list is empty (no terminal nodes found) - what should happen?
    59       return possibleSymbolsList.SelectRandom(new MersenneTwister()).CreateTreeNode();
     54      // only select specific symbols, which can be interpreted ...
     55      var possibleSymbolsList = (from s in grammar.GetAllowedChildSymbols(parentNode.Symbol)
     56                                 where s.InitialFrequency > 0.0
     57                                 where s.MaximumArity == 0
     58                                 where s.MinimumArity == 0
     59                                 select s).ToList();
     60      // TODO: Check, if symbol list is empty (no terminal nodes found) - what should happen?
     61      var newNode = possibleSymbolsList.SelectRandom(new MersenneTwister()).CreateTreeNode();
     62      if (newNode.HasLocalParameters) newNode.ResetLocalParameters(new MersenneTwister());
     63      return newNode;
    6064    }
    6165
     
    7478                                                          int genotypeIndex) {
    7579
    76       IEnumerable<ISymbol> symbolList = grammar.GetAllowedChildSymbols(parentNode.Symbol);
     80      // only select specific symbols, which can be interpreted ...
     81      IEnumerable<ISymbol> symbolList = (from s in grammar.GetAllowedChildSymbols(parentNode.Symbol)
     82                                         where s.InitialFrequency > 0.0
     83                                         select s).ToList();
    7784      int prodRuleCount = symbolList.Count();
    7885      int prodRuleIndex = genotype[genotypeIndex % genotype.Length] % prodRuleCount;
    7986
    80       return symbolList.ElementAt(prodRuleIndex).CreateTreeNode();
     87      var newNode = symbolList.ElementAt(prodRuleIndex).CreateTreeNode();
     88      if (newNode.HasLocalParameters) newNode.ResetLocalParameters(new MersenneTwister());
     89      return newNode;
    8190    }
    8291  }
Note: See TracChangeset for help on using the changeset viewer.