Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/18/17 10:36:37 (8 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/VariableBase.cs

    r14238 r14758  
    3434      get { return weightMu; }
    3535      set {
    36         if (value != weightMu) {
     36        if(value != weightMu) {
    3737          weightMu = value;
    3838          OnChanged(EventArgs.Empty);
     
    4545      get { return weightSigma; }
    4646      set {
    47         if (weightSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
    48         if (value != weightSigma) {
     47        if(weightSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
     48        if(value != weightSigma) {
    4949          weightSigma = value;
    5050          OnChanged(EventArgs.Empty);
     
    5757      get { return weightManipulatorMu; }
    5858      set {
    59         if (value != weightManipulatorMu) {
     59        if(value != weightManipulatorMu) {
    6060          weightManipulatorMu = value;
    6161          OnChanged(EventArgs.Empty);
     
    6868      get { return weightManipulatorSigma; }
    6969      set {
    70         if (weightManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
    71         if (value != weightManipulatorSigma) {
     70        if(weightManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
     71        if(value != weightManipulatorSigma) {
    7272          weightManipulatorSigma = value;
    7373          OnChanged(EventArgs.Empty);
     
    8080      get { return multiplicativeWeightManipulatorSigma; }
    8181      set {
    82         if (multiplicativeWeightManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
    83         if (value != multiplicativeWeightManipulatorSigma) {
     82        if(multiplicativeWeightManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
     83        if(value != multiplicativeWeightManipulatorSigma) {
    8484          multiplicativeWeightManipulatorSigma = value;
    8585          OnChanged(EventArgs.Empty);
     
    8787      }
    8888    }
     89
     90    [Storable(DefaultValue = 1.0)]
     91    private double variableChangeProbability;
     92
     93    public double VariableChangeProbability {
     94      get { return VariableChangeProbability; }
     95      set {
     96        if(value < 0 || value > 1.0) throw new ArgumentException("Variable change probability must lie in the interval [0..1]");
     97        variableChangeProbability = value;
     98      }
     99    }
     100
    89101    private List<string> variableNames;
    90102    [Storable]
     
    92104      get { return variableNames; }
    93105      set {
    94         if (value == null) throw new ArgumentNullException();
     106        if(value == null) throw new ArgumentNullException();
    95107        variableNames.Clear();
    96108        variableNames.AddRange(value);
     
    104116      get { return allVariableNames; }
    105117      set {
    106         if (value == null) throw new ArgumentNullException();
     118        if(value == null) throw new ArgumentNullException();
    107119        allVariableNames.Clear();
    108120        allVariableNames.AddRange(value);
     
    112124    public override bool Enabled {
    113125      get {
    114         if (variableNames.Count == 0) return false;
     126        if(variableNames.Count == 0) return false;
    115127        return base.Enabled;
    116128      }
    117129      set {
    118         if (variableNames.Count == 0) base.Enabled = false;
     130        if(variableNames.Count == 0) base.Enabled = false;
    119131        else base.Enabled = value;
    120132      }
     
    134146    [StorableHook(HookType.AfterDeserialization)]
    135147    private void AfterDeserialization() {
    136       if (allVariableNames == null || (allVariableNames.Count == 0 && variableNames.Count > 0)) {
     148      if(allVariableNames == null || (allVariableNames.Count == 0 && variableNames.Count > 0)) {
    137149        allVariableNames = variableNames;
    138150      }
     
    154166      weightManipulatorSigma = original.weightManipulatorSigma;
    155167      multiplicativeWeightManipulatorSigma = original.multiplicativeWeightManipulatorSigma;
    156     }
     168      variableChangeProbability = original.variableChangeProbability;
     169      }
    157170    protected VariableBase(string name, string description)
    158171      : base(name, description) {
     
    162175      weightManipulatorSigma = 0.05;
    163176      multiplicativeWeightManipulatorSigma = 0.03;
     177      variableChangeProbability = 0.2;
    164178      variableNames = new List<string>();
    165179      allVariableNames = new List<string>();
Note: See TracChangeset for help on using the changeset viewer.