Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/23/10 14:27:06 (15 years ago)
Author:
gkronber
Message:

Implemented manipulation operators. #937 (Data types and operators for symbolic expression tree encoding)

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

    r3485 r3512  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     30using System;
    3031namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
    3132  [StorableClass]
     
    4546      set { maxValue = value; }
    4647    }
     48    [Storable]
     49    private double manipulatorNu;
     50    public double ManipulatorNu {
     51      get { return manipulatorNu; }
     52      set { manipulatorNu = value; }
     53    }
     54    [Storable]
     55    private double manipulatorSigma;
     56    public double ManipulatorSigma {
     57      get { return manipulatorSigma; }
     58      set {
     59        if (value < 0) throw new ArgumentException();
     60        manipulatorSigma = value;
     61      }
     62    }
    4763    #endregion
    4864    public Constant()
    4965      : base() {
     66      manipulatorNu = 0.0;
     67      manipulatorSigma = 1.0;
     68      minValue = -20.0;
     69      maxValue = 20.0;
    5070    }
    5171
     
    5575
    5676    public override IDeepCloneable Clone(Cloner cloner) {
    57       Constant clone = (Constant) base.Clone(cloner);
     77      Constant clone = (Constant)base.Clone(cloner);
    5878      clone.minValue = minValue;
    5979      clone.maxValue = maxValue;
     80      clone.manipulatorNu = manipulatorNu;
     81      clone.manipulatorSigma = manipulatorSigma;
    6082      return clone;
    6183    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/ConstantTreeNode.cs

    r3485 r3512  
    6363    }
    6464
     65    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
     66      base.ShakeLocalParameters(random, shakingFactor);
     67      var normalDistributedRNG = new NormalDistributedRandom(random, Symbol.ManipulatorNu, Symbol.ManipulatorSigma);
     68      double x = normalDistributedRNG.NextDouble();
     69      Value = Value + x * shakingFactor;
     70    }
     71
    6572    public override object Clone() {
    6673      return new ConstantTreeNode(this);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Variable.cs

    r3485 r3512  
    5252    }
    5353    [Storable]
     54    private double weightManipulatorNu;
     55    public double WeightManipulatorNu {
     56      get { return weightManipulatorNu; }
     57      set { weightManipulatorNu = value; }
     58    }
     59    [Storable]
     60    private double weightManipulatorSigma;
     61    public double WeightManipulatorSigma {
     62      get { return weightManipulatorSigma; }
     63      set {
     64        if (weightManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
     65        weightManipulatorSigma = value;
     66      }
     67    }
     68    [Storable]
    5469    private List<string> variableNames;
    5570    public IEnumerable<string> VariableNames {
     
    6681      weightNu = 1.0;
    6782      weightSigma = 1.0;
     83      weightManipulatorNu = 0.0;
     84      weightManipulatorSigma = 1.0;
    6885      variableNames = new List<string>();
    6986    }
     
    7895      clone.weightSigma = weightSigma;
    7996      clone.variableNames = new List<string>(variableNames);
     97      clone.weightManipulatorNu = weightManipulatorNu;
     98      clone.weightManipulatorSigma = weightManipulatorSigma;
    8099      return clone;
    81100    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/VariableTreeNode.cs

    r3485 r3512  
    6969      var normalDistributedRNG = new NormalDistributedRandom(random, Symbol.WeightNu, Symbol.WeightSigma);
    7070      weight = normalDistributedRNG.NextDouble();
    71       var variableList = new List<string>(Symbol.VariableNames);
    72       int variableIndex = random.Next(0, variableList.Count);
    73       variableName = variableList[variableIndex];
     71      variableName = Symbol.VariableNames.SelectRandom(random);
    7472    }
     73
     74    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
     75      base.ShakeLocalParameters(random, shakingFactor);
     76      var normalDistributedRNG = new NormalDistributedRandom(random, Symbol.WeightManipulatorNu, Symbol.WeightManipulatorSigma);
     77      double x = normalDistributedRNG.NextDouble();
     78      weight = weight + x * shakingFactor;
     79      variableName = Symbol.VariableNames.SelectRandom(random);
     80    }
     81
    7582
    7683    public override object Clone() {
Note: See TracChangeset for help on using the changeset viewer.