Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/18/17 10:36:37 (7 years ago)
Author:
gkronber
Message:

#2650 unified mutation behaviour for all variable tree nodes. Introduced parameter for probability of changing a variable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/FactorVariableTreeNode.cs

    r14717 r14758  
    7575
    7676    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
    77       if(random.NextDouble() < 0.2) {
     77      // mutate only one randomly selected weight
     78      var idx = random.Next(weights.Length);
     79      // 50% additive & 50% multiplicative
     80      if(random.NextDouble() < 0.5) {
     81        double x = NormalDistributedRandom.NextDouble(random, Symbol.WeightManipulatorMu,
     82          Symbol.WeightManipulatorSigma);
     83        weights[idx] = weights[idx] + x * shakingFactor;
     84      } else {
     85        double x = NormalDistributedRandom.NextDouble(random, 1.0, Symbol.MultiplicativeWeightManipulatorSigma);
     86        weights[idx] = weights[idx] * x;
     87      }
     88      if(random.NextDouble() < Symbol.VariableChangeProbability) {
    7889        VariableName = Symbol.VariableNames.SampleRandom(random);
    7990        if(weights.Length != Symbol.GetVariableValues(VariableName).Count()) {
     
    8394              .Select(_ => NormalDistributedRandom.NextDouble(random, 0, 1))
    8495              .ToArray();
    85         }
    86       } else {
    87         // mutate only one randomly selected weight
    88         var idx = random.Next(weights.Length);
    89         // 50% additive & 50% multiplicative
    90         if(random.NextDouble() < 0.5) {
    91           double x = NormalDistributedRandom.NextDouble(random, Symbol.WeightManipulatorMu,
    92             Symbol.WeightManipulatorSigma);
    93           weights[idx] = weights[idx] + x * shakingFactor;
    94         } else {
    95           double x = NormalDistributedRandom.NextDouble(random, 1.0, Symbol.MultiplicativeWeightManipulatorSigma);
    96           weights[idx] = weights[idx] * x;
    9796        }
    9897      }
Note: See TracChangeset for help on using the changeset viewer.