[11494] | 1 | #region License Information
|
---|
| 2 |
|
---|
| 3 | /* HeuristicLab
|
---|
[14186] | 4 | * Copyright (C) 2002-2016 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 |
|
---|
| 24 | using System;
|
---|
| 25 | using System.Collections.Generic;
|
---|
| 26 | using System.Linq;
|
---|
| 27 | using HeuristicLab.Common;
|
---|
| 28 | using HeuristicLab.Core;
|
---|
[11874] | 29 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[11494] | 30 |
|
---|
| 31 | namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
|
---|
[11874] | 32 |
|
---|
| 33 | [StorableClass]
|
---|
[11494] | 34 | internal sealed class EmptySymbolicExpressionTreeGrammar : NamedItem, ISymbolicExpressionTreeGrammar {
|
---|
[11874] | 35 | [Storable]
|
---|
[11494] | 36 | private ISymbolicExpressionGrammar grammar;
|
---|
[11874] | 37 |
|
---|
| 38 | [StorableConstructor]
|
---|
[12706] | 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 |
|
---|
[12706] | 72 | public IEnumerable<ISymbol> GetAllowedChildSymbols(ISymbol parent) {
|
---|
[11494] | 73 | return grammar.GetAllowedChildSymbols(parent);
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[12706] | 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 |
|
---|
[12706] | 87 | public int GetMinimumExpressionDepth(ISymbol symbol) {
|
---|
[11494] | 88 | return grammar.GetMinimumExpressionDepth(symbol);
|
---|
| 89 | }
|
---|
[12706] | 90 | public int GetMaximumExpressionDepth(ISymbol symbol) {
|
---|
[11494] | 91 | return grammar.GetMaximumExpressionDepth(symbol);
|
---|
| 92 | }
|
---|
[12706] | 93 | public int GetMinimumExpressionLength(ISymbol symbol) {
|
---|
[11494] | 94 | return grammar.GetMinimumExpressionLength(symbol);
|
---|
| 95 | }
|
---|
[12706] | 96 | public int GetMaximumExpressionLength(ISymbol symbol, int maxDepth) {
|
---|
[11494] | 97 | return grammar.GetMaximumExpressionLength(symbol, maxDepth);
|
---|
| 98 | }
|
---|
| 99 |
|
---|
[12706] | 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 |
|
---|
[12706] | 108 |
|
---|
[11494] | 109 | #region ISymbolicExpressionTreeGrammar Members
|
---|
[12706] | 110 | public IEnumerable<ISymbol> ModifyableSymbols {
|
---|
[11494] | 111 | get { return Enumerable.Empty<ISymbol>(); }
|
---|
| 112 | }
|
---|
| 113 |
|
---|
[12706] | 114 | public bool IsModifyableSymbol(ISymbol symbol) {
|
---|
[11494] | 115 | return false;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
[12706] | 118 | #pragma warning disable 0067 //disable usage warning
|
---|
[11494] | 119 | public event EventHandler Changed;
|
---|
[12706] | 120 | #pragma warning restore 0067
|
---|
[11494] | 121 | #endregion
|
---|
| 122 | }
|
---|
| 123 | }
|
---|