Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/EmptySymbolicExpressionTreeGrammar.cs @ 13365

Last change on this file since 13365 was 12422, checked in by mkommend, 10 years ago

#2320: Merged the encoding class and all accompanying changes in the trunk.

File size: 4.6 KB
RevLine 
[11494]1#region License Information
2
3/* HeuristicLab
[12012]4 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[11494]5 *
6 * This file is part of HeuristicLab.
7 *
8 * HeuristicLab is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * HeuristicLab is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#endregion
23
24using System;
25using System.Collections.Generic;
26using System.Linq;
27using HeuristicLab.Common;
28using HeuristicLab.Core;
[11532]29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
[11494]30
31namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
[11532]32
33  [StorableClass]
[11494]34  internal sealed class EmptySymbolicExpressionTreeGrammar : NamedItem, ISymbolicExpressionTreeGrammar {
[11532]35    [Storable]
[11494]36    private ISymbolicExpressionGrammar grammar;
[11532]37
38    [StorableConstructor]
[12422]39    private EmptySymbolicExpressionTreeGrammar(bool deserializing) : base(deserializing) { }
[11494]40    internal EmptySymbolicExpressionTreeGrammar(ISymbolicExpressionGrammar grammar)
41      : base() {
42      if (grammar == null) throw new ArgumentNullException();
43      this.grammar = grammar;
44    }
45
46    public override IDeepCloneable Clone(Cloner cloner) {
47      return this;
48    }
49
50    public IEnumerable<ISymbol> Symbols {
51      get { return grammar.Symbols; }
52    }
53    public IEnumerable<ISymbol> AllowedSymbols {
54      get { return grammar.AllowedSymbols; }
55    }
56
57    public ISymbol GetSymbol(string symbolName) {
58      return grammar.GetSymbol(symbolName);
59    }
60
61    public bool ContainsSymbol(ISymbol symbol) {
62      return grammar.ContainsSymbol(symbol);
63    }
64
65    public bool IsAllowedChildSymbol(ISymbol parent, ISymbol child) {
66      return grammar.IsAllowedChildSymbol(parent, child);
67    }
68    public bool IsAllowedChildSymbol(ISymbol parent, ISymbol child, int argumentIndex) {
69      return grammar.IsAllowedChildSymbol(parent, child, argumentIndex);
70    }
71
[12422]72    public IEnumerable<ISymbol> GetAllowedChildSymbols(ISymbol parent) {
[11494]73      return grammar.GetAllowedChildSymbols(parent);
74    }
75
[12422]76    public IEnumerable<ISymbol> GetAllowedChildSymbols(ISymbol parent, int argumentIndex) {
[11494]77      return grammar.GetAllowedChildSymbols(parent, argumentIndex);
78    }
79
80    public int GetMinimumSubtreeCount(ISymbol symbol) {
81      return grammar.GetMinimumSubtreeCount(symbol);
82    }
83    public int GetMaximumSubtreeCount(ISymbol symbol) {
84      return grammar.GetMaximumSubtreeCount(symbol);
85    }
86
[12422]87    public int GetMinimumExpressionDepth(ISymbol symbol) {
[11494]88      return grammar.GetMinimumExpressionDepth(symbol);
89    }
[12422]90    public int GetMaximumExpressionDepth(ISymbol symbol) {
[11494]91      return grammar.GetMaximumExpressionDepth(symbol);
92    }
[12422]93    public int GetMinimumExpressionLength(ISymbol symbol) {
[11494]94      return grammar.GetMinimumExpressionLength(symbol);
95    }
[12422]96    public int GetMaximumExpressionLength(ISymbol symbol, int maxDepth) {
[11494]97      return grammar.GetMaximumExpressionLength(symbol, maxDepth);
98    }
99
[12422]100    public void AddSymbol(ISymbol symbol) { throw new NotSupportedException(); }
101    public void RemoveSymbol(ISymbol symbol) { throw new NotSupportedException(); }
102    public void AddAllowedChildSymbol(ISymbol parent, ISymbol child) { throw new NotSupportedException(); }
103    public void AddAllowedChildSymbol(ISymbol parent, ISymbol child, int argumentIndex) { throw new NotSupportedException(); }
104    public void RemoveAllowedChildSymbol(ISymbol parent, ISymbol child) { throw new NotSupportedException(); }
105    public void RemoveAllowedChildSymbol(ISymbol parent, ISymbol child, int argumentIndex) { throw new NotSupportedException(); }
106    public void SetSubtreeCount(ISymbol symbol, int minimumSubtreeCount, int maximumSubtreeCount) { throw new NotSupportedException(); }
[11494]107
[12422]108
[11494]109    #region ISymbolicExpressionTreeGrammar Members
[12422]110    public IEnumerable<ISymbol> ModifyableSymbols {
[11494]111      get { return Enumerable.Empty<ISymbol>(); }
112    }
113
[12422]114    public bool IsModifyableSymbol(ISymbol symbol) {
[11494]115      return false;
116    }
117
[12422]118#pragma warning disable 0067 //disable usage warning
[11494]119    public event EventHandler Changed;
[12422]120#pragma warning restore 0067
[11494]121    #endregion
122  }
123}
Note: See TracBrowser for help on using the repository browser.