[3294] | 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 |
|
---|
| 22 | using System.Linq;
|
---|
[3376] | 23 | using HeuristicLab.Common;
|
---|
[3294] | 24 | using HeuristicLab.Core;
|
---|
| 25 | using HeuristicLab.Data;
|
---|
| 26 | using HeuristicLab.Operators;
|
---|
| 27 | using HeuristicLab.Optimization;
|
---|
| 28 | using HeuristicLab.Parameters;
|
---|
| 29 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[3534] | 30 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;
|
---|
[3294] | 31 |
|
---|
| 32 | namespace 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 |
|
---|
[3338] | 48 | #region Parameter Properties
|
---|
[3294] | 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 | }
|
---|
[3338] | 61 | #endregion
|
---|
[3294] | 62 |
|
---|
[3338] | 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 |
|
---|
[3294] | 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 | }
|
---|