Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 3494 was 3376, checked in by swagner, 15 years ago

Moved interfaces and classes for deep cloning from HeuristicLab.Core to HeuristicLab.Common (#975).

File size: 4.5 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 System.Linq;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
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 SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
40    private const string MaxTreeSizeParameterName = "MaxTreeSize";
41    private const string MaxTreeHeightParameterName = "MaxTreeHeight";
42    private const string SymbolicExpressionGrammarParameterName = "SymbolicExpressionGrammar";
43
44    public override bool CanChangeName {
45      get { return false; }
46    }
47
48    #region Parameter Properties
49    public ILookupParameter<IRandom> RandomParameter {
50      get { return (LookupParameter<IRandom>)Parameters[RandomParameterName]; }
51    }
52    public ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
53      get { return (ILookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
54    }
55    public IValueLookupParameter<IntValue> MaxTreeSizeParameter {
56      get { return (IValueLookupParameter<IntValue>)Parameters[MaxTreeSizeParameterName]; }
57    }
58    public IValueLookupParameter<IntValue> MaxTreeHeightParameter {
59      get { return (IValueLookupParameter<IntValue>)Parameters[MaxTreeHeightParameterName]; }
60    }
61    public ILookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionGrammarParameter {
62      get { return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionGrammarParameterName]; }
63    }
64    #endregion
65
66    #region Properties
67    public IRandom Random {
68      get { return RandomParameter.ActualValue; }
69    }
70    public SymbolicExpressionTree SymbolicExpressionTree {
71      get { return SymbolicExpressionTreeParameter.ActualValue; }
72    }
73    public IntValue MaxTreeSize {
74      get { return MaxTreeSizeParameter.ActualValue; }
75    }
76    public IntValue MaxTreeHeight {
77      get { return MaxTreeHeightParameter.ActualValue; }
78    }
79    public ISymbolicExpressionGrammar SymbolicExpressionGrammar {
80      get { return SymbolicExpressionGrammarParameter.ActualValue; }
81    }
82    #endregion
83
84    protected SymbolicExpressionTreeOperator()
85      : base() {
86      Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The pseudo random number generator which should be used for symbolic expression tree operators."));
87      Parameters.Add(new LookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree on which the operator should be applied."));
88      Parameters.Add(new ValueLookupParameter<IntValue>(MaxTreeSizeParameterName, "The maximal size (number of nodes) of the symbolic expression tree."));
89      Parameters.Add(new ValueLookupParameter<IntValue>(MaxTreeHeightParameterName, "The maximal height of the symbolic expression tree (a tree with one node has height = 0)."));
90      Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionGrammarParameterName, "The grammar that defines the allowed symbols and syntax of the symbolic expression trees."));
91    }
92  }
93}
Note: See TracBrowser for help on using the repository browser.