Changeset 18006 for branches/3087_Ceres_Integration/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
- Timestamp:
- 07/13/21 10:55:09 (3 years ago)
- Location:
- branches/3087_Ceres_Integration
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3087_Ceres_Integration
- Property svn:mergeinfo changed
-
branches/3087_Ceres_Integration/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
/branches/3105_PythonFormatter/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding (added) merged: 17918 /trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding (added) merged: 17871-17872,17922
- Property svn:mergeinfo changed
-
branches/3087_Ceres_Integration/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs
r17491 r18006 55 55 get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; } 56 56 } 57 public IFixedValueParameter< DoubleValue> CrossoverProbabilityParameter {58 get { return (IFixedValueParameter< DoubleValue>)Parameters[CrossoverProbabilityParameterName]; }57 public IFixedValueParameter<PercentValue> CrossoverProbabilityParameter { 58 get { return (IFixedValueParameter<PercentValue>)Parameters[CrossoverProbabilityParameterName]; } 59 59 } 60 60 #endregion … … 81 81 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree.")); 82 82 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0).")); 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)));83 Parameters.Add(new ValueLookupParameter<PercentValue>(InternalCrossoverPointProbabilityParameterName, "The probability to select an internal crossover point (instead of a leaf node).", new PercentValue(0.9, true))); 84 Parameters.Add(new FixedValueParameter<PercentValue>(CrossoverProbabilityParameterName, "The probability that a crossover is performed. Otherwise a copy of the first parent is returned.", new PercentValue(1, true))); 85 85 } 86 86 87 87 [StorableHook(HookType.AfterDeserialization)] 88 88 private void AfterDeserialization() { 89 // replace with PercentValue for files which had CrossoverProbability as DoubleValue 90 if (Parameters.ContainsKey(CrossoverProbabilityParameterName) && (Parameters[CrossoverProbabilityParameterName] is IFixedValueParameter<DoubleValue> oldParam)) { 91 var oldValue = oldParam.Value.Value; 92 Parameters.Remove(oldParam); 93 Parameters.Add(new FixedValueParameter<PercentValue>(CrossoverProbabilityParameterName, "The probability that a crossover is performed. Otherwise a copy of the first parent is returned.", new PercentValue(oldValue))); 94 } 89 95 if (!Parameters.ContainsKey(CrossoverProbabilityParameterName)) { 90 Parameters.Add(new FixedValueParameter< DoubleValue>(CrossoverProbabilityParameterName, "", new DoubleValue(1)));96 Parameters.Add(new FixedValueParameter<PercentValue>(CrossoverProbabilityParameterName, "The probability that a crossover is performed. Otherwise a copy of the first parent is returned.", new PercentValue(1, true))); 91 97 } 92 98 } … … 106 112 double probability, 107 113 double internalCrossoverPointProbability, int maxTreeLength, int maxTreeDepth) { 108 if ((probability < 1) && (random.NextDouble() >= probability)) return random.NextDouble() < 0.5 ? parent0 : parent1;114 if ((probability < 1) && (random.NextDouble() >= probability)) return parent0; 109 115 // select a random crossover point in the first parent 110 116 CutPoint crossoverPoint0;
Note: See TracChangeset
for help on using the changeset viewer.