Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/27/21 14:10:56 (4 years ago)
Author:
pfleck
Message:

#3040 Merged trunk into branch.

Location:
branches/3040_VectorBasedGP
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3040_VectorBasedGP

  • branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

  • branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs

    r17180 r17825  
    4343    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
    4444    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
     45    private const string CrossoverProbabilityParameterName = "CrossoverProbability";
    4546
    4647    #region Parameter Properties
     
    5354    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
    5455      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
     56    }
     57    public IFixedValueParameter<DoubleValue> CrossoverProbabilityParameter {
     58      get { return (IFixedValueParameter<DoubleValue>)Parameters[CrossoverProbabilityParameterName]; }
    5559    }
    5660    #endregion
     
    6468    public IntValue MaximumSymbolicExpressionTreeDepth {
    6569      get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }
     70    }
     71    public double CrossoverProbability {
     72      get { return CrossoverProbabilityParameter.Value.Value; }
     73      set { CrossoverProbabilityParameter.Value.Value = value; }
    6674    }
    6775    #endregion
     
    7482      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    7583      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      }
    7692    }
    7793
     
    8298    public override ISymbolicExpressionTree Crossover(IRandom random,
    8399      ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {
    84       return Cross(random, parent0, parent1, InternalCrossoverPointProbability.Value,
     100      return Cross(random, parent0, parent1, CrossoverProbability, InternalCrossoverPointProbability.Value,
    85101        MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
    86102    }
     
    88104    public static ISymbolicExpressionTree Cross(IRandom random,
    89105      ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1,
     106      double probability,
    90107      double internalCrossoverPointProbability, int maxTreeLength, int maxTreeDepth) {
     108      if ((probability < 1) && (random.NextDouble() >= probability)) return random.NextDouble() < 0.5 ? parent0 : parent1;
    91109      // select a random crossover point in the first parent
    92110      CutPoint crossoverPoint0;
  • branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SimpleSymbolicExpressionGrammar.cs

    r17180 r17825  
    2121
    2222using System.Collections.Generic;
     23using HEAL.Attic;
    2324using HeuristicLab.Common;
    24 using HEAL.Attic;
    2525
    2626namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    5555      }
    5656    }
    57     public void AddSymbols(IEnumerable<string> symbolNames, int minimumArity, int maximiumArity) {
    58       foreach (var symbolName in symbolNames) AddSymbol(symbolName, minimumArity, maximiumArity);
     57    public void AddSymbols(IEnumerable<string> symbolNames, int minimumArity, int maximumArity) {
     58      foreach (var symbolName in symbolNames) AddSymbol(symbolName, minimumArity, maximumArity);
    5959    }
    6060
Note: See TracChangeset for help on using the changeset viewer.