Changeset 17825 for branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Timestamp:
- 01/27/21 14:10:56 (4 years ago)
- Location:
- branches/3040_VectorBasedGP
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3040_VectorBasedGP
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding merged: 17458,17490-17491
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs
r17180 r17825 43 43 private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength"; 44 44 private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth"; 45 private const string CrossoverProbabilityParameterName = "CrossoverProbability"; 45 46 46 47 #region Parameter Properties … … 53 54 public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter { 54 55 get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; } 56 } 57 public IFixedValueParameter<DoubleValue> CrossoverProbabilityParameter { 58 get { return (IFixedValueParameter<DoubleValue>)Parameters[CrossoverProbabilityParameterName]; } 55 59 } 56 60 #endregion … … 64 68 public IntValue MaximumSymbolicExpressionTreeDepth { 65 69 get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; } 70 } 71 public double CrossoverProbability { 72 get { return CrossoverProbabilityParameter.Value.Value; } 73 set { CrossoverProbabilityParameter.Value.Value = value; } 66 74 } 67 75 #endregion … … 74 82 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0).")); 75 83 Parameters.Add(new ValueLookupParameter<PercentValue>(InternalCrossoverPointProbabilityParameterName, "The probability to select an internal crossover point (instead of a leaf node).", new PercentValue(0.9))); 84 Parameters.Add(new FixedValueParameter<DoubleValue>(CrossoverProbabilityParameterName, "", new DoubleValue(1))); 85 } 86 87 [StorableHook(HookType.AfterDeserialization)] 88 private void AfterDeserialization() { 89 if (!Parameters.ContainsKey(CrossoverProbabilityParameterName)) { 90 Parameters.Add(new FixedValueParameter<DoubleValue>(CrossoverProbabilityParameterName, "", new DoubleValue(1))); 91 } 76 92 } 77 93 … … 82 98 public override ISymbolicExpressionTree Crossover(IRandom random, 83 99 ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) { 84 return Cross(random, parent0, parent1, InternalCrossoverPointProbability.Value,100 return Cross(random, parent0, parent1, CrossoverProbability, InternalCrossoverPointProbability.Value, 85 101 MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value); 86 102 } … … 88 104 public static ISymbolicExpressionTree Cross(IRandom random, 89 105 ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1, 106 double probability, 90 107 double internalCrossoverPointProbability, int maxTreeLength, int maxTreeDepth) { 108 if ((probability < 1) && (random.NextDouble() >= probability)) return random.NextDouble() < 0.5 ? parent0 : parent1; 91 109 // select a random crossover point in the first parent 92 110 CutPoint crossoverPoint0; -
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SimpleSymbolicExpressionGrammar.cs
r17180 r17825 21 21 22 22 using System.Collections.Generic; 23 using HEAL.Attic; 23 24 using HeuristicLab.Common; 24 using HEAL.Attic;25 25 26 26 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 55 55 } 56 56 } 57 public void AddSymbols(IEnumerable<string> symbolNames, int minimumArity, int maxim iumArity) {58 foreach (var symbolName in symbolNames) AddSymbol(symbolName, minimumArity, maxim iumArity);57 public void AddSymbols(IEnumerable<string> symbolNames, int minimumArity, int maximumArity) { 58 foreach (var symbolName in symbolNames) AddSymbol(symbolName, minimumArity, maximumArity); 59 59 } 60 60
Note: See TracChangeset
for help on using the changeset viewer.