Free cookie consent management tool by TermsFeed Policy Generator

source: branches/CloningRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeOperator.cs @ 4656

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

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

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