Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11494


Ignore:
Timestamp:
10/24/14 16:45:06 (9 years ago)
Author:
mkommend
Message:

#2268: Moved all grammar classes into a new folder. Added new EmptySymbolicExpressionTreeGrammar which is immutable and forwards all calls to the default grammar object.

Location:
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
Files:
2 added
2 edited
3 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammar.cs

    r11490 r11494  
    110110      set { defunSymbol = (Defun)value; }
    111111    }
     112
     113    private readonly ISymbolicExpressionTreeGrammar emptyGrammar;
    112114    #endregion
    113115
     
    117119        RegisterSymbolEvents(symbol);
    118120    }
     121
    119122    [StorableConstructor]
    120     protected SymbolicExpressionGrammar(bool deserializing) : base(deserializing) { }
     123    protected SymbolicExpressionGrammar(bool deserializing)
     124      : base(deserializing) {
     125      emptyGrammar = new EmptySymbolicExpressionTreeGrammar(this);
     126    }
    121127    protected SymbolicExpressionGrammar(SymbolicExpressionGrammar original, Cloner cloner)
    122128      : base(original, cloner) {
     129      emptyGrammar = new EmptySymbolicExpressionTreeGrammar(this);
     130
    123131      foreach (ISymbol symbol in symbols.Values)
    124132        RegisterSymbolEvents(symbol);
     
    134142    }
    135143
    136     public SymbolicExpressionGrammar(string name, string description)
     144    protected SymbolicExpressionGrammar(string name, string description)
    137145      : base(name, description) {
     146      emptyGrammar = new EmptySymbolicExpressionTreeGrammar(this);
     147
    138148      programRootSymbol = new ProgramRootSymbol();
    139149      AddSymbol(programRootSymbol);
     
    160170        AddAllowedChildSymbol(programRootSymbol, defunSymbol, argumentIndex);
    161171      }
     172    }
     173
     174    public ISymbolicExpressionTreeGrammar CreateExpressionTreeGrammar() {
     175      if (MaximumFunctionDefinitions == 0) return emptyGrammar;
     176      else return new SymbolicExpressionTreeGrammar(this);
    162177    }
    163178
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammarBase.cs

    r11490 r11494  
    6464
    6565    private bool suppressEvents;
    66     protected Dictionary<string, ISymbol> symbols;
    67     protected Dictionary<string, Tuple<int, int>> symbolSubtreeCount;
    68     protected Dictionary<string, List<string>> allowedChildSymbols;
    69     protected Dictionary<Tuple<string, int>, List<string>> allowedChildSymbolsPerIndex;
     66    protected internal Dictionary<string, ISymbol> symbols;
     67    protected internal Dictionary<string, Tuple<int, int>> symbolSubtreeCount;
     68    protected internal Dictionary<string, List<string>> allowedChildSymbols;
     69    protected internal Dictionary<Tuple<string, int>, List<string>> allowedChildSymbolsPerIndex;
    7070
    7171    public override bool CanChangeName {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj

    r10562 r11494  
    136136    <Compile Include="Formatters\SymbolicExpressionTreeGraphvizFormatter.cs" />
    137137    <Compile Include="Formatters\SymbolicExpressionTreeHierarchicalFormatter.cs" />
     138    <Compile Include="Grammars\EmptySymbolicExpressionTreeGrammar.cs" />
    138139    <Compile Include="Interfaces\IReadOnlySymbol.cs" />
    139140    <Compile Include="Interfaces\ISymbolicExpressionGrammar.cs" />
     
    166167    <Compile Include="Manipulators\SymbolicExpressionTreeManipulator.cs" />
    167168    <Compile Include="Plugin.cs" />
    168     <Compile Include="SymbolicExpressionGrammarBase.cs" />
    169     <Compile Include="SymbolicExpressionGrammar.cs" />
    170     <Compile Include="SymbolicExpressionTreeGrammar.cs" />
     169    <Compile Include="Grammars\SymbolicExpressionGrammarBase.cs" />
     170    <Compile Include="Grammars\SymbolicExpressionGrammar.cs" />
     171    <Compile Include="Grammars\SymbolicExpressionTreeGrammar.cs" />
    171172    <Compile Include="SymbolicExpressionTreeTopLevelNode.cs" />
    172173    <Compile Include="Crossovers\SubtreeCrossover.cs">
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionGrammar.cs

    r11171 r11494  
    4848    void StartGrammarManipulation();
    4949    void FinishedGrammarManipulation();
     50
     51    ISymbolicExpressionTreeGrammar CreateExpressionTreeGrammar();
    5052  }
    5153}
Note: See TracChangeset for help on using the changeset viewer.