Changeset 7268 for branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/RampedHalfAndHalfTreeCreator.cs
- Timestamp:
- 01/03/12 11:22:21 (13 years ago)
- Location:
- branches/HeuristicLab.TimeSeries
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries
- Property svn:mergeinfo changed
/trunk/sources merged: 7214,7216-7230,7233-7239,7241,7243-7252,7254,7256-7261,7265-7266
- Property svn:mergeinfo changed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/RampedHalfAndHalfTreeCreator.cs
r7034 r7268 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.ComponentModel;25 using System.Linq;26 22 using HeuristicLab.Common; 27 23 using HeuristicLab.Core; … … 54 50 public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter { 55 51 get { 56 return 57 (IValueLookupParameter<ISymbolicExpressionGrammar>) 58 Parameters[SymbolicExpressionTreeGrammarParameterName]; 52 return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; 59 53 } 60 54 } … … 62 56 public ILookupParameter<ISymbolicExpressionGrammar> ClonedSymbolicExpressionTreeGrammarParameter { 63 57 get { 64 return 65 (ILookupParameter<ISymbolicExpressionGrammar>) 66 Parameters[ClonedSymbolicExpressionTreeGrammarParameterName]; 58 return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[ClonedSymbolicExpressionTreeGrammarParameterName]; 67 59 } 68 60 } … … 78 70 } 79 71 80 public ISymbolicExpressionGrammar SymbolicExpressionTreeGrammar {72 public ISymbolicExpressionGrammar ClonedSymbolicExpressionTreeGrammar { 81 73 get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; } 82 74 } … … 89 81 public RampedHalfAndHalfTreeCreator() 90 82 : base() { 91 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree.")); 92 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0).")); 93 Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, "The tree grammar that defines the correct syntax of symbolic expression trees that should be created.")); 94 Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName, "An immutable clone of the concrete grammar that is actually used to create and manipulate trees.")); 83 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, 84 "The maximal length (number of nodes) of the symbolic expression tree (this parameter is ignored).")); 85 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, 86 "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0).")); 87 Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, 88 "The tree grammar that defines the correct syntax of symbolic expression trees that should be created.")); 89 Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName, 90 "An immutable clone of the concrete grammar that is actually used to create and manipulate trees.")); 95 91 } 96 92 … … 106 102 globalScope = globalScope.Parent; 107 103 108 globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone())); 104 globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, 105 (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone())); 109 106 } 110 107 return base.Apply(); … … 112 109 113 110 protected override ISymbolicExpressionTree Create(IRandom random) { 114 return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);111 return Create(random, ClonedSymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value); 115 112 } 116 113 … … 125 122 /// <param name="random">Random generator</param> 126 123 /// <param name="grammar">Available tree grammar</param> 124 /// <param name="maxTreeLength">Maximum tree length (this parameter is ignored)</param> 127 125 /// <param name="maxTreeDepth">Maximum tree depth</param> 128 126 /// <returns></returns> … … 134 132 135 133 var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode(); 134 if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random); 136 135 startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar)); 137 if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);138 136 139 137 rootNode.AddSubtree(startNode); … … 142 140 143 141 if (p < 0.5) 144 GrowTreeCreator. Grow(random, startNode, maxTreeDepth - 2);142 GrowTreeCreator.Create(random, startNode, maxTreeDepth - 2); 145 143 else 146 FullTreeCreator. Grow(random, startNode, maxTreeDepth - 2);144 FullTreeCreator.Create(random, startNode, maxTreeDepth - 2); 147 145 148 146 tree.Root = rootNode;
Note: See TracChangeset
for help on using the changeset viewer.