Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/18/11 16:09:35 (14 years ago)
Author:
gkronber
Message:

Implemented multiplicative manipulation of constants and variable weights. #1384

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Constant.cs

    r4989 r5326  
    3030  [Item("Constant", "Represents a constant value.")]
    3131  public sealed class Constant : Symbol {
    32     #region Propeties
     32    #region Properties
    3333    [Storable]
    3434    private double minValue;
     
    7676      }
    7777    }
     78    [Storable(DefaultValue = 0.0)]
     79    private double multiplicativeManipulatorSigma;
     80    public double MultiplicativeManipulatorSigma {
     81      get { return multiplicativeManipulatorSigma; }
     82      set {
     83        if (value < 0) throw new ArgumentException();
     84        if (value != multiplicativeManipulatorSigma) {
     85          multiplicativeManipulatorSigma = value;
     86          OnChanged(EventArgs.Empty);
     87        }
     88      }
     89    }
     90
    7891    #endregion
    7992    [StorableConstructor]
     
    8598      manipulatorMu = original.manipulatorMu;
    8699      manipulatorSigma = original.manipulatorSigma;
     100      multiplicativeManipulatorSigma = original.multiplicativeManipulatorSigma;
    87101    }
    88102    public Constant()
     
    90104      manipulatorMu = 0.0;
    91105      manipulatorSigma = 1.0;
     106      multiplicativeManipulatorSigma = 0.03;
    92107      minValue = -20.0;
    93108      maxValue = 20.0;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/ConstantTreeNode.cs

    r4989 r5326  
    6363    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
    6464      base.ShakeLocalParameters(random, shakingFactor);
    65       double x = NormalDistributedRandom.NextDouble(random, Symbol.ManipulatorMu, Symbol.ManipulatorSigma);
    66       Value = Value + x * shakingFactor;
     65      // 50% additive & 50% multiplicative
     66      if (random.NextDouble() < 0.5) {
     67        double x = NormalDistributedRandom.NextDouble(random, Symbol.ManipulatorMu, Symbol.ManipulatorSigma);
     68        Value = Value + x * shakingFactor;
     69      } else {
     70        double x = NormalDistributedRandom.NextDouble(random, 1.0, Symbol.MultiplicativeManipulatorSigma);
     71        Value = Value * x;
     72      }
    6773    }
    6874
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Variable.cs

    r4989 r5326  
    7878      }
    7979    }
     80    [Storable(DefaultValue = 0.0)]
     81    private double multiplicativeWeightManipulatorSigma;
     82    public double MultiplicativeWeightManipulatorSigma {
     83      get { return multiplicativeWeightManipulatorSigma; }
     84      set {
     85        if (multiplicativeWeightManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
     86        if (value != multiplicativeWeightManipulatorSigma) {
     87          multiplicativeWeightManipulatorSigma = value;
     88          OnChanged(EventArgs.Empty);
     89        }
     90      }
     91    }
    8092    private List<string> variableNames;
    8193    [Storable]
     
    91103    #endregion
    92104    [StorableConstructor]
    93     protected Variable(bool deserializing) : base(deserializing) {
     105    protected Variable(bool deserializing)
     106      : base(deserializing) {
    94107      variableNames = new List<string>();
    95108    }
     
    101114      weightManipulatorMu = original.weightManipulatorMu;
    102115      weightManipulatorSigma = original.weightManipulatorSigma;
     116      multiplicativeWeightManipulatorSigma = original.multiplicativeWeightManipulatorSigma;
    103117    }
    104118    public Variable() : this("Variable", "Represents a variable value.") { }
     
    109123      weightManipulatorMu = 0.0;
    110124      weightManipulatorSigma = 1.0;
     125      multiplicativeWeightManipulatorSigma = 0.03;
    111126      variableNames = new List<string>();
    112127    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/VariableTreeNode.cs

    r4989 r5326  
    6868    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
    6969      base.ShakeLocalParameters(random, shakingFactor);
    70       double x = NormalDistributedRandom.NextDouble(random, Symbol.WeightManipulatorMu, Symbol.WeightManipulatorSigma);
    71       weight = weight + x * shakingFactor;
     70      // 50% additive & 50% multiplicative
     71      if (random.NextDouble() < 0) {
     72        double x = NormalDistributedRandom.NextDouble(random, Symbol.WeightManipulatorMu, Symbol.WeightManipulatorSigma);
     73        weight = weight + x * shakingFactor;
     74      } else {       
     75        double x = NormalDistributedRandom.NextDouble(random, 1.0, Symbol.MultiplicativeWeightManipulatorSigma);
     76        weight = weight * x;
     77      }
    7278      variableName = Symbol.VariableNames.SelectRandom(random);
    7379    }
Note: See TracChangeset for help on using the changeset viewer.