1 | #region License Information
|
---|
2 |
|
---|
3 | /* HeuristicLab
|
---|
4 | * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
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;
|
---|
29 |
|
---|
30 | namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
|
---|
31 | internal sealed class EmptySymbolicExpressionTreeGrammar : NamedItem, ISymbolicExpressionTreeGrammar {
|
---|
32 | private ISymbolicExpressionGrammar grammar;
|
---|
33 | internal EmptySymbolicExpressionTreeGrammar(ISymbolicExpressionGrammar grammar)
|
---|
34 | : base() {
|
---|
35 | if (grammar == null) throw new ArgumentNullException();
|
---|
36 | this.grammar = grammar;
|
---|
37 | }
|
---|
38 |
|
---|
39 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
40 | return this;
|
---|
41 | }
|
---|
42 |
|
---|
43 | public IEnumerable<ISymbol> Symbols {
|
---|
44 | get { return grammar.Symbols; }
|
---|
45 | }
|
---|
46 | public IEnumerable<ISymbol> AllowedSymbols {
|
---|
47 | get { return grammar.AllowedSymbols; }
|
---|
48 | }
|
---|
49 |
|
---|
50 | public ISymbol GetSymbol(string symbolName) {
|
---|
51 | return grammar.GetSymbol(symbolName);
|
---|
52 | }
|
---|
53 |
|
---|
54 | public bool ContainsSymbol(ISymbol symbol) {
|
---|
55 | return grammar.ContainsSymbol(symbol);
|
---|
56 | }
|
---|
57 |
|
---|
58 | public bool IsAllowedChildSymbol(ISymbol parent, ISymbol child) {
|
---|
59 | return grammar.IsAllowedChildSymbol(parent, child);
|
---|
60 | }
|
---|
61 | public bool IsAllowedChildSymbol(ISymbol parent, ISymbol child, int argumentIndex) {
|
---|
62 | return grammar.IsAllowedChildSymbol(parent, child, argumentIndex);
|
---|
63 | }
|
---|
64 |
|
---|
65 | IEnumerable<ISymbol> ISymbolicExpressionGrammarBase.GetAllowedChildSymbols(ISymbol parent) {
|
---|
66 | return grammar.GetAllowedChildSymbols(parent);
|
---|
67 | }
|
---|
68 |
|
---|
69 | IEnumerable<ISymbol> ISymbolicExpressionGrammarBase.GetAllowedChildSymbols(ISymbol parent, int argumentIndex) {
|
---|
70 | return grammar.GetAllowedChildSymbols(parent, argumentIndex);
|
---|
71 | }
|
---|
72 |
|
---|
73 | public int GetMinimumSubtreeCount(ISymbol symbol) {
|
---|
74 | return grammar.GetMinimumSubtreeCount(symbol);
|
---|
75 | }
|
---|
76 | public int GetMaximumSubtreeCount(ISymbol symbol) {
|
---|
77 | return grammar.GetMaximumSubtreeCount(symbol);
|
---|
78 | }
|
---|
79 |
|
---|
80 | int ISymbolicExpressionGrammarBase.GetMinimumExpressionDepth(ISymbol symbol) {
|
---|
81 | return grammar.GetMinimumExpressionDepth(symbol);
|
---|
82 | }
|
---|
83 | int ISymbolicExpressionGrammarBase.GetMaximumExpressionDepth(ISymbol symbol) {
|
---|
84 | return grammar.GetMaximumExpressionDepth(symbol);
|
---|
85 | }
|
---|
86 | int ISymbolicExpressionGrammarBase.GetMinimumExpressionLength(ISymbol symbol) {
|
---|
87 | return grammar.GetMinimumExpressionLength(symbol);
|
---|
88 | }
|
---|
89 | int ISymbolicExpressionGrammarBase.GetMaximumExpressionLength(ISymbol symbol, int maxDepth) {
|
---|
90 | return grammar.GetMaximumExpressionLength(symbol, maxDepth);
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | #region ISymbolicExpressionTreeGrammar Members
|
---|
95 | IEnumerable<ISymbol> ISymbolicExpressionTreeGrammar.ModifyableSymbols {
|
---|
96 | get { return Enumerable.Empty<ISymbol>(); }
|
---|
97 | }
|
---|
98 |
|
---|
99 | bool ISymbolicExpressionTreeGrammar.IsModifyableSymbol(ISymbol symbol) {
|
---|
100 | return false;
|
---|
101 | }
|
---|
102 |
|
---|
103 | void ISymbolicExpressionTreeGrammar.AddSymbol(ISymbol symbol) {
|
---|
104 | throw new NotSupportedException();
|
---|
105 | }
|
---|
106 |
|
---|
107 | void ISymbolicExpressionTreeGrammar.RemoveSymbol(ISymbol symbol) {
|
---|
108 | throw new NotSupportedException();
|
---|
109 | }
|
---|
110 |
|
---|
111 | void ISymbolicExpressionTreeGrammar.AddAllowedChildSymbol(ISymbol parent, ISymbol child) {
|
---|
112 | throw new NotSupportedException();
|
---|
113 | }
|
---|
114 |
|
---|
115 | void ISymbolicExpressionTreeGrammar.AddAllowedChildSymbol(ISymbol parent, ISymbol child, int argumentIndex) {
|
---|
116 | throw new NotSupportedException();
|
---|
117 | }
|
---|
118 |
|
---|
119 | void ISymbolicExpressionTreeGrammar.RemoveAllowedChildSymbol(ISymbol parent, ISymbol child) {
|
---|
120 | throw new NotSupportedException();
|
---|
121 | }
|
---|
122 |
|
---|
123 | void ISymbolicExpressionTreeGrammar.RemoveAllowedChildSymbol(ISymbol parent, ISymbol child, int argumentIndex) {
|
---|
124 | throw new NotSupportedException();
|
---|
125 | }
|
---|
126 |
|
---|
127 | void ISymbolicExpressionTreeGrammar.SetSubtreeCount(ISymbol symbol, int minimumSubtreeCount, int maximumSubtreeCount) {
|
---|
128 | throw new NotSupportedException();
|
---|
129 | }
|
---|
130 |
|
---|
131 | public event EventHandler Changed;
|
---|
132 | #endregion
|
---|
133 | }
|
---|
134 | }
|
---|