Changeset 17918 for branches/3105_PythonFormatter/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Timestamp:
- 03/29/21 09:54:58 (4 years ago)
- Location:
- branches/3105_PythonFormatter
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3105_PythonFormatter
- Property svn:mergeinfo changed
/trunk (added) merged: 17845,17856,17858-17859,17861,17867,17871-17873,17888-17889,17902-17903,17906-17914
- Property svn:mergeinfo changed
-
branches/3105_PythonFormatter/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding (added) merged: 17871-17872
- Property svn:mergeinfo changed
-
branches/3105_PythonFormatter/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs
r17491 r17918 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.