Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.MultiVariate/3.3/Symbolic/MultiVariateExpressionGrammar.cs @ 4098

Last change on this file since 4098 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

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    public MultiVariateExpressionGrammar() : this(2) { }
40
41    public MultiVariateExpressionGrammar(int dimension)
42      : base() {
43      this.dimension = dimension;
44    }
45
46    protected MultiVariateExpressionGrammar(MultiVariateExpressionGrammar original)
47      : base(original) {
48      this.dimension = original.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      var clone = new MultiVariateExpressionGrammar(this);
66      cloner.RegisterClonedObject(this, clone);
67      return clone;
68    }
69  }
70}
Note: See TracBrowser for help on using the repository browser.