Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/05/16 14:25:28 (8 years ago)
Author:
gkronber
Message:

#2650: work in progress..

File:
1 edited

Legend:

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

    r14233 r14237  
    2727namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    2828  [StorableClass]
    29   public class FactorVariableTreeNode : SymbolicExpressionTreeTerminalNode {
     29  public class FactorVariableTreeNode : VariableTreeNodeBase {
    3030    public new FactorVariable Symbol {
    3131      get { return (FactorVariable)base.Symbol; }
    32     }
    33     [Storable]
    34     private string variableName;
    35     public string VariableName {
    36       get { return variableName; }
    37       set { variableName = value; }
    3832    }
    3933
     
    4943    protected FactorVariableTreeNode(FactorVariableTreeNode original, Cloner cloner)
    5044      : base(original, cloner) {
    51       variableName = original.variableName;
    5245      variableValue = original.variableValue;
    5346    }
     
    6154    public override void ResetLocalParameters(IRandom random) {
    6255      base.ResetLocalParameters(random);
    63       variableName = Symbol.VariableNames.SampleRandom(random);
    6456      variableValue = Symbol.GetVariableValues(VariableName).SampleRandom(random);
    6557    }
    6658
    6759    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
    68       base.ShakeLocalParameters(random, shakingFactor);
     60      // 50% additive & 50% multiplicative
     61      if (random.NextDouble() < 0.5) {
     62        double x = NormalDistributedRandom.NextDouble(random, Symbol.WeightManipulatorMu, Symbol.WeightManipulatorSigma);
     63        Weight = Weight + x * shakingFactor;
     64      } else {
     65        double x = NormalDistributedRandom.NextDouble(random, 1.0, Symbol.MultiplicativeWeightManipulatorSigma);
     66        Weight = Weight * x;
     67      }
    6968      if (random.NextDouble() < 0.2) {
    70         variableName = Symbol.VariableNames.SampleRandom(random);
     69        VariableName = Symbol.VariableNames.SampleRandom(random);
    7170      }
    7271      variableValue = Symbol.GetVariableValues(VariableName).SampleRandom(random);
     
    7877
    7978    public override string ToString() {
    80       return variableName + " = " + variableValue;
     79      return base.ToString() + " = " + variableValue;
    8180    }
    8281  }
Note: See TracChangeset for help on using the changeset viewer.