Changeset 14831


Ignore:
Timestamp:
04/06/17 11:42:05 (2 years ago)
Author:
gkronber
Message:

#2650 made backwards compatibe code for mutation of variables more obvious in VariableTreeNodeBase

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VariableTreeNodeBase.cs

    r14826 r14831  
    7979      }
    8080
    81       if (Symbol.VariableChangeProbability >= 1.0 || random.NextDouble() < Symbol.VariableChangeProbability) {
    82         var oldName = variableName;
     81      if (Symbol.VariableChangeProbability >= 1.0) {
     82        // old behaviour for backwards compatibility
     83        #region Backwards compatible code, remove with 3.4
    8384#pragma warning disable 612, 618
    8485        variableName = Symbol.VariableNames.SelectRandom(random);
    8586#pragma warning restore 612, 618
     87        #endregion
     88      } else if (random.NextDouble() < Symbol.VariableChangeProbability) {
     89        var oldName = variableName;
     90        variableName = Symbol.VariableNames.SampleRandom(random);
    8691        if (oldName != variableName) {
     92          // re-initialize weight if the variable is changed
    8793          weight = NormalDistributedRandom.NextDouble(random, Symbol.WeightMu, Symbol.WeightSigma);
    8894        }
Note: See TracChangeset for help on using the changeset viewer.