Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/29/21 09:54:58 (4 years ago)
Author:
mkommend
Message:

#3105: Merge trunk changes into branch.

Location:
branches/3105_PythonFormatter
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3105_PythonFormatter

  • branches/3105_PythonFormatter/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

  • branches/3105_PythonFormatter/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs

    r17491 r17918  
    5555      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
    5656    }
    57     public IFixedValueParameter<DoubleValue> CrossoverProbabilityParameter {
    58       get { return (IFixedValueParameter<DoubleValue>)Parameters[CrossoverProbabilityParameterName]; }
     57    public IFixedValueParameter<PercentValue> CrossoverProbabilityParameter {
     58      get { return (IFixedValueParameter<PercentValue>)Parameters[CrossoverProbabilityParameterName]; }
    5959    }
    6060    #endregion
     
    8181      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
    8282      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)));
    8585    }
    8686
    8787    [StorableHook(HookType.AfterDeserialization)]
    8888    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      }
    8995      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)));
    9197      }
    9298    }
     
    106112      double probability,
    107113      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;
    109115      // select a random crossover point in the first parent
    110116      CutPoint crossoverPoint0;
Note: See TracChangeset for help on using the changeset viewer.