- Timestamp:
- 03/09/21 11:24:27 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs
r17491 r17871 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)) { 91 var oldValue = ((IFixedValueParameter<DoubleValue>)Parameters[CrossoverProbabilityParameterName]).Value.Value; 92 Parameters.Remove(CrossoverProbabilityParameterName); 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.