Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/03/10 13:26:02 (14 years ago)
Author:
abeham
Message:

#1179

  • Added program root symbol
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation.GP/3.3/Grammar/FullFunctionalExpressionGrammar.cs

    r4089 r4364  
    2121
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3940
    4041    private void Initialize() {
     42      var originalStart = StartSymbol;
     43      if (!(originalStart is ProgramRootSymbol)) {
     44        var root = new ProgramRootSymbol();
     45        AddSymbol(root);
     46        SetMinSubtreeCount(root, 1);
     47        SetMaxSubtreeCount(root, 1);
     48        SetAllowedChild(root, originalStart, 0);
     49
     50        StartSymbol = root;
     51      }
     52
    4153      var add = new Addition();
    4254      var sub = new Subtraction();
     
    90102      // allow each symbol as child of the start symbol
    91103      foreach (var symb in allSymbols) {
    92         SetAllowedChild(StartSymbol, symb, 0);
     104        SetAllowedChild(originalStart, symb, 0);
    93105      }
    94106
Note: See TracChangeset for help on using the changeset viewer.