Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/08/10 11:20:08 (13 years ago)
Author:
gkronber
Message:

Fixed a problem with ADFs in symbolic expression grammars. #922

File:
1 edited

Legend:

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

    r4722 r4742  
    9898      }
    9999
    100       SetMinSubtreeCount(StartSymbol, minFunctionDefinitions + 1);
    101       SetMaxSubtreeCount(StartSymbol, maxFunctionDefinitions + 1);
    102       SetMinSubtreeCount(defunSymbol, 1);
     100      SetMinSubtreeCount(StartSymbol, minFunctionDefinitions + 1); // min number of ADF + 1 for RPB
     101      SetMaxSubtreeCount(StartSymbol, maxFunctionDefinitions + 1); // max number of ADF + 1 for RPB
     102      // defun can have only one child
     103      SetMinSubtreeCount(defunSymbol, 1);
    103104      SetMaxSubtreeCount(defunSymbol, 1);
     105
    104106
    105107      // the start symbol of the mainBranchGrammar is allowed as the result producing branch
    106108      SetAllowedChild(StartSymbol, Symbols.Where(s => s.Name == mainBranchGrammar.StartSymbol.Name).First(), 0);
     109
     110      // defuns are allowed as children on the same level and after RPB
     111      for (int i = 0; i < maxFunctionDefinitions; i++) {
     112        // +1 because RPB has index 0
     113        SetAllowedChild(StartSymbol, defunSymbol, i + 1);
     114      }
    107115
    108116      // every symbol of the mainBranchGrammar that is allowed as child of the start symbol is also allowed as direct child of defun
Note: See TracChangeset for help on using the changeset viewer.