Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/09/10 17:01:36 (14 years ago)
Author:
gkronber
Message:

Worked on symbolic regression classes to prepare for time series prognosis plugin. #1081

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/LaggedVariable.cs

    r3993 r4022  
    3434  [StorableClass]
    3535  [Item("LaggedVariable", "Represents a variable value with a time offset.")]
    36   public sealed class LaggedVariable : Symbol {
    37     #region Properties
    38     [Storable]
    39     private double weightNu;
    40     public double WeightNu {
    41       get { return weightNu; }
    42       set { weightNu = value; }
    43     }
    44     [Storable]
    45     private double weightSigma;
    46     public double WeightSigma {
    47       get { return weightSigma; }
    48       set {
    49         if (weightSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
    50         weightSigma = value;
    51       }
    52     }
    53     [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     private List<string> variableNames;
    69     [Storable]
    70     public IEnumerable<string> VariableNames {
    71       get { return variableNames; }
    72       set {
    73         if (value == null) throw new ArgumentNullException();
    74         variableNames.Clear();
    75         variableNames.AddRange(value);
    76       }
    77     }
     36  public sealed class LaggedVariable : Variable {
     37    //#region Properties
     38    //[Storable]
     39    //private double weightNu;
     40    //public double WeightNu {
     41    //  get { return weightNu; }
     42    //  set { weightNu = value; }
     43    //}
     44    //[Storable]
     45    //private double weightSigma;
     46    //public double WeightSigma {
     47    //  get { return weightSigma; }
     48    //  set {
     49    //    if (weightSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
     50    //    weightSigma = value;
     51    //  }
     52    //}
     53    //[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    //private List<string> variableNames;
     69    //[Storable]
     70    //public IEnumerable<string> VariableNames {
     71    //  get { return variableNames; }
     72    //  set {
     73    //    if (value == null) throw new ArgumentNullException();
     74    //    variableNames.Clear();
     75    //    variableNames.AddRange(value);
     76    //  }
     77    //}
    7878    [Storable]
    7979    private int minLag;
     
    8888      set { maxLag = value; }
    8989    }
    90     #endregion
     90    //#endregion
    9191    public LaggedVariable()
    9292      : base("LaggedVariable", "Represents a variable value with a time offset.") {
    93       weightNu = 1.0;
    94       weightSigma = 1.0;
    95       weightManipulatorNu = 0.0;
    96       weightManipulatorSigma = 1.0;
    97       variableNames = new List<string>();
    98       minLag = 0; maxLag = 0;
     93      //weightNu = 1.0;
     94      //weightSigma = 1.0;
     95      //weightManipulatorNu = 0.0;
     96      //weightManipulatorSigma = 1.0;
     97      //variableNames = new List<string>();
     98      minLag = -1; maxLag = -1;
    9999    }
    100100
     
    105105    public override IDeepCloneable Clone(Cloner cloner) {
    106106      LaggedVariable clone = (LaggedVariable)base.Clone(cloner);
    107       clone.weightNu = weightNu;
    108       clone.weightSigma = weightSigma;
    109       clone.variableNames = new List<string>(variableNames);
    110       clone.weightManipulatorNu = weightManipulatorNu;
    111       clone.weightManipulatorSigma = weightManipulatorSigma;
     107      //clone.weightNu = weightNu;
     108      //clone.weightSigma = weightSigma;
     109      //clone.variableNames = new List<string>(variableNames);
     110      //clone.weightManipulatorNu = weightManipulatorNu;
     111      //clone.weightManipulatorSigma = weightManipulatorSigma;
    112112      clone.minLag = minLag;
    113113      clone.maxLag = maxLag;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/LaggedVariableTreeNode.cs

    r3997 r4022  
    3030namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
    3131  [StorableClass]
    32   public sealed class LaggedVariableTreeNode : SymbolicExpressionTreeTerminalNode {
     32  public sealed class LaggedVariableTreeNode : VariableTreeNode {
    3333    public new LaggedVariable Symbol {
    3434      get { return (LaggedVariable)base.Symbol; }
    35     }
    36     [Storable]
    37     private double weight;
    38     public double Weight {
    39       get { return weight; }
    40       set { weight = value; }
    41     }
    42     [Storable]
    43     private string variableName;
    44     public string VariableName {
    45       get { return variableName; }
    46       set { variableName = value; }
    4735    }
    4836    [Storable]
     
    5846    private LaggedVariableTreeNode(LaggedVariableTreeNode original)
    5947      : base(original) {
    60       weight = original.weight;
    61       variableName = original.variableName;
    6248      lag = original.lag;
    6349    }
     
    7359    public override void ResetLocalParameters(IRandom random) {
    7460      base.ResetLocalParameters(random);
    75       weight = NormalDistributedRandom.NextDouble(random, Symbol.WeightNu, Symbol.WeightSigma);
    76       variableName = Symbol.VariableNames.SelectRandom(random);
    7761      lag = random.Next(Symbol.MinLag, Symbol.MaxLag + 1);
    7862    }
     
    8064    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
    8165      base.ShakeLocalParameters(random, shakingFactor);
    82       double x = NormalDistributedRandom.NextDouble(random, Symbol.WeightManipulatorNu, Symbol.WeightManipulatorSigma);
    83       weight = weight + x * shakingFactor;
    84       variableName = Symbol.VariableNames.SelectRandom(random);
    85       lag = lag + random.Next(-1, 2);
     66      lag = Math.Min(Symbol.MaxLag, Math.Max(Symbol.MinLag, lag + random.Next(-1, 2)));
    8667    }
    8768
     
    9273
    9374    public override string ToString() {
    94       return weight.ToString("E4") + " " + variableName + " (t" + (lag > 0 ? "+" : "") + lag + ")";
     75      return base.ToString() +
     76        " (t" + (lag > 0 ? "+" : "") + lag + ")";
    9577    }
    9678  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Variable.cs

    r3993 r4022  
    3434  [StorableClass]
    3535  [Item("Variable", "Represents a variable value.")]
    36   public sealed class Variable : Symbol {
     36  public class Variable : Symbol {
    3737    #region Properties
    3838    [Storable]
     
    9494    }
    9595    #endregion
    96     public Variable()
    97       : base("Variable", "Represents a variable value.") {
     96    public Variable() : this("Variable", "Represents a variable value.") { }
     97    public Variable(string name, string description)
     98      : base(name, description) {
    9899      weightNu = 1.0;
    99100      weightSigma = 1.0;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/VariableTreeNode.cs

    r3997 r4022  
    3030namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
    3131  [StorableClass]
    32   public sealed class VariableTreeNode : SymbolicExpressionTreeTerminalNode {
     32  public class VariableTreeNode : SymbolicExpressionTreeTerminalNode {
    3333    public new Variable Symbol {
    3434      get { return (Variable)base.Symbol; }
     
    4848
    4949
    50     private VariableTreeNode() { }
     50    protected VariableTreeNode() { }
    5151
    5252    // copy constructor
    53     private VariableTreeNode(VariableTreeNode original)
     53    protected VariableTreeNode(VariableTreeNode original)
    5454      : base(original) {
    5555      weight = original.weight;
Note: See TracChangeset for help on using the changeset viewer.