Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate/3.3/Symbolic/MultiVariateExpressionGrammar.cs @ 7923

Last change on this file since 7923 was 5275, checked in by gkronber, 14 years ago

Merged changes from trunk to data analysis exploration branch and added fractional distance metric evaluator. #1142

File size: 2.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
25using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Problems.DataAnalysis.MultiVariate.Symbolic {
29  [StorableClass]
30  [Item("MultiVariateExpressionGrammar", "Represents a grammar for multi-variate expressions using all available functions.")]
31  public class MultiVariateExpressionGrammar : DefaultSymbolicExpressionGrammar {
32
33    [Storable]
34    private int dimension;
35    public int Dimension {
36      get { return dimension; }
37    }
38
39    [StorableConstructor]
40    protected MultiVariateExpressionGrammar(bool deserializing) : base(deserializing) { }
41    protected MultiVariateExpressionGrammar(MultiVariateExpressionGrammar original, Cloner cloner)
42      : base(original, cloner) {
43        dimension = original.dimension;
44    }
45    public MultiVariateExpressionGrammar() : this(2) { }
46    public MultiVariateExpressionGrammar(int dimension)
47      : base() {
48      this.dimension = dimension;
49    }
50
51    public void SetDimension(int n) {
52      dimension = n;
53      SetMinSubtreeCount(StartSymbol, n);
54      SetMaxSubtreeCount(StartSymbol, n);
55
56      foreach (Symbol s in Symbols) {
57        if (s != StartSymbol)
58          for (int i = 0; i < n; i++) {
59            SetAllowedChild(StartSymbol, s, i);
60          }
61      }
62    }
63
64    public override IDeepCloneable Clone(Cloner cloner) {
65      return new MultiVariateExpressionGrammar(this, cloner);
66    }
67  }
68}
Note: See TracBrowser for help on using the repository browser.