Changeset 12706 for stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs
- Timestamp:
- 07/10/15 12:02:20 (9 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 12422,12424,12480-12482
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs
r12009 r12706 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Data;28 using HeuristicLab.Parameters;29 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 28 using HeuristicLab.PluginInfrastructure; … … 37 35 ISymbolicExpressionTreeSizeConstraintOperator, ISymbolicExpressionTreeGrammarBasedOperator { 38 36 private const int MAX_TRIES = 100; 39 private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";40 private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";41 #region Parameter Properties42 public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {43 get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }44 }45 public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {46 get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }47 }48 #endregion49 #region Properties50 public IntValue MaximumSymbolicExpressionTreeLength {51 get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }52 }53 public IntValue MaximumSymbolicExpressionTreeDepth {54 get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }55 }56 #endregion57 37 58 38 [StorableConstructor] … … 61 41 public ProbabilisticTreeCreator() 62 42 : base() { 63 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree.")); 64 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0).")); 43 65 44 } 66 45 … … 71 50 72 51 protected override ISymbolicExpressionTree Create(IRandom random) { 73 return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value); 52 return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue, 53 MaximumSymbolicExpressionTreeLengthParameter.ActualValue.Value, MaximumSymbolicExpressionTreeDepthParameter.ActualValue.Value); 74 54 } 75 55 … … 186 166 if (allowedSymbols.Count == 0) return false; 187 167 var weights = allowedSymbols.Select(x => x.InitialFrequency).ToList(); 168 169 #pragma warning disable 612, 618 188 170 var selectedSymbol = allowedSymbols.SelectRandom(weights, random); 171 #pragma warning restore 612, 618 172 189 173 ISymbolicExpressionTreeNode newTree = selectedSymbol.CreateTreeNode(); 190 174 if (newTree.HasLocalParameters) newTree.ResetLocalParameters(random); … … 232 216 select g).First().ToList(); 233 217 var weights = possibleSymbols.Select(x => x.InitialFrequency).ToList(); 218 219 #pragma warning disable 612, 618 234 220 var selectedSymbol = possibleSymbols.SelectRandom(weights, random); 221 #pragma warning restore 612, 618 222 235 223 var tree = selectedSymbol.CreateTreeNode(); 236 224 if (tree.HasLocalParameters) tree.ResetLocalParameters(random);
Note: See TracChangeset
for help on using the changeset viewer.