Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 4047 was 3534, checked in by gkronber, 15 years ago

Added interfaces for symbolic expression tree operators and added multi manipulation operators. #937 (Data types and operators for symbolic expression tree encoding)

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