Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeOperator.cs @ 5413

Last change on this file since 5413 was 4722, checked in by swagner, 14 years ago

Merged cloning refactoring branch back into trunk (#922)

File size: 4.2 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.Data;
25using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;
26using HeuristicLab.Operators;
27using HeuristicLab.Optimization;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30
31namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
32  /// <summary>
33  /// A base class for operators for symbolic expression trees.
34  /// </summary>
35  [Item("SymbolicExpressionTreeOperator", "A base class for operators for symbolic expression trees.")]
36  [StorableClass]
37  public abstract class SymbolicExpressionTreeOperator : SingleSuccessorOperator, IStochasticOperator, ISymbolicExpressionTreeOperator {
38    private const string RandomParameterName = "Random";
39    private const string MaxTreeSizeParameterName = "MaxTreeSize";
40    private const string MaxTreeHeightParameterName = "MaxTreeHeight";
41    private const string SymbolicExpressionGrammarParameterName = "SymbolicExpressionGrammar";
42
43    public override bool CanChangeName {
44      get { return false; }
45    }
46
47    #region Parameter Properties
48    public ILookupParameter<IRandom> RandomParameter {
49      get { return (LookupParameter<IRandom>)Parameters[RandomParameterName]; }
50    }
51    public IValueLookupParameter<IntValue> MaxTreeSizeParameter {
52      get { return (IValueLookupParameter<IntValue>)Parameters[MaxTreeSizeParameterName]; }
53    }
54    public IValueLookupParameter<IntValue> MaxTreeHeightParameter {
55      get { return (IValueLookupParameter<IntValue>)Parameters[MaxTreeHeightParameterName]; }
56    }
57    public ILookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionGrammarParameter {
58      get { return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionGrammarParameterName]; }
59    }
60    #endregion
61
62    #region Properties
63    public IRandom Random {
64      get { return RandomParameter.ActualValue; }
65    }
66    public IntValue MaxTreeSize {
67      get { return MaxTreeSizeParameter.ActualValue; }
68    }
69    public IntValue MaxTreeHeight {
70      get { return MaxTreeHeightParameter.ActualValue; }
71    }
72    public ISymbolicExpressionGrammar SymbolicExpressionGrammar {
73      get { return SymbolicExpressionGrammarParameter.ActualValue; }
74    }
75    #endregion
76
77    [StorableConstructor]
78    protected SymbolicExpressionTreeOperator(bool deserializing) : base(deserializing) { }
79    protected SymbolicExpressionTreeOperator(SymbolicExpressionTreeOperator original, Cloner cloner) : base(original, cloner) { }
80    protected SymbolicExpressionTreeOperator()
81      : base() {
82      Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The pseudo random number generator which should be used for symbolic expression tree operators."));
83      Parameters.Add(new ValueLookupParameter<IntValue>(MaxTreeSizeParameterName, "The maximal size (number of nodes) of the symbolic expression tree."));
84      Parameters.Add(new ValueLookupParameter<IntValue>(MaxTreeHeightParameterName, "The maximal height of the symbolic expression tree (a tree with one node has height = 0)."));
85      Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionGrammarParameterName, "The grammar that defines the allowed symbols and syntax of the symbolic expression trees."));
86    }
87  }
88}
Note: See TracBrowser for help on using the repository browser.