Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/09/10 17:28:32 (14 years ago)
Author:
gkronber
Message:

Added first version of architecture altering operators for ADFs. #290 (Implement ADFs)

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

Legend:

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

    r3269 r3294  
    3131  [Item("Constant", "Represents a constant value.")]
    3232  public sealed class Constant : Symbol {
    33     #region Parameter Properties
    34     public IValueParameter<DoubleValue> MinValueParameter {
    35       get { return (IValueParameter<DoubleValue>)Parameters["MinValue"]; }
     33    #region Propeties
     34    private double minValue;
     35    public double MinValue {
     36      get { return minValue; }
     37      set { minValue = value; }
    3638    }
    37     public IValueParameter<DoubleValue> MaxValueParameter {
    38       get { return (IValueParameter<DoubleValue>)Parameters["MaxValue"]; }
    39     }
    40     #endregion
    41     #region Propeties
    42     public DoubleValue MinValue {
    43       get { return MinValueParameter.Value; }
    44       set { MinValueParameter.Value = value; }
    45     }
    46     public DoubleValue MaxValue {
    47       get { return MaxValueParameter.Value; }
    48       set { MaxValueParameter.Value = value; }
     39    private double maxValue;
     40    public double MaxValue {
     41      get { return maxValue; }
     42      set { maxValue = value; }
    4943    }
    5044    #endregion
    5145    public Constant()
    5246      : base() {
    53       Parameters.Add(new ValueParameter<DoubleValue>("MinValue", "The minimal value of the constant.", new DoubleValue(-20.0)));
    54       Parameters.Add(new ValueParameter<DoubleValue>("MaxValue", "The maximal value of the constant.", new DoubleValue(20.0)));
    5547    }
    5648
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Symbols/ConstantTreeNode.cs

    r3269 r3294  
    5555    public override void ResetLocalParameters(IRandom random) {
    5656      base.ResetLocalParameters(random);
    57       var range = Symbol.MaxValue.Value - Symbol.MaxValue.Value;
    58       Value = random.NextDouble() * range - Symbol.MinValue.Value;
     57      var range = Symbol.MaxValue - Symbol.MaxValue;
     58      Value = random.NextDouble() * range - Symbol.MinValue;
    5959    }
    6060
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Symbols/Variable.cs

    r3269 r3294  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828using HeuristicLab.Parameters;
     29using System.Collections.Generic;
     30using System;
    2931namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Symbols {
    3032  [StorableClass]
    3133  [Item("Variable", "Represents a variable value.")]
    3234  public sealed class Variable : Symbol {
    33     #region Parameter Properties
    34     public IValueParameter<DoubleValue> WeightNuParameter {
    35       get { return (IValueParameter<DoubleValue>)Parameters["WeightNu"]; }
     35    #region Properties
     36    private double weightNu;
     37    [Storable]
     38    public double WeightNu {
     39      get { return weightNu; }
     40      set { weightNu = value; }
    3641    }
    37     public IValueParameter<DoubleValue> WeightSigmaParameter {
    38       get { return (IValueParameter<DoubleValue>)Parameters["WeightSigma"]; }
     42    private double weightSigma;
     43    [Storable]
     44    public double WeightSigma {
     45      get { return weightSigma; }
     46      set {
     47        if (weightSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
     48        weightSigma = value;
     49      }
    3950    }
    40     public IValueParameter<ItemList<StringValue>> VariableNamesParameter {
    41       get { return (IValueParameter<ItemList<StringValue>>)Parameters["VariableNames"]; }
    42     }
    43     #endregion
    44     #region Properties
    45     public DoubleValue WeightNu {
    46       get { return WeightNuParameter.Value; }
    47       set { WeightNuParameter.Value = value; }
    48     }
    49     public DoubleValue WeightSigma {
    50       get { return WeightSigmaParameter.Value; }
    51       set { WeightSigmaParameter.Value = value; }
    52     }
    53     public ItemList<StringValue> VariableNames {
    54       get { return VariableNamesParameter.Value; }
    55       set { VariableNamesParameter.Value = value; }
     51    private List<string> variableNames;
     52    [Storable]
     53    public ICollection<string> VariableNames {
     54      get { return variableNames; }
     55      set {
     56        if (value == null) throw new ArgumentNullException();
     57        variableNames.Clear();
     58        variableNames.AddRange(value);
     59      }
    5660    }
    5761    #endregion
    5862    public Variable()
    5963      : base() {
    60       Parameters.Add(new ValueParameter<DoubleValue>("WeightNu", "The mean value for the initialization of weight ((N(nu, sigma)).", new DoubleValue(1.0)));
    61       Parameters.Add(new ValueParameter<DoubleValue>("WeightSigma", "The sigma value for the initialization of weight (N(nu, sigma))", new DoubleValue(1.0)));
    62       Parameters.Add(new ValueParameter<ItemList<StringValue>>("VariableNames", "The list of possible variable names for initialization."));
     64      weightNu = 1.0;
     65      weightSigma = 1.0;
     66      variableNames = new List<string>();
    6367    }
    6468
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Symbols/VariableTreeNode.cs

    r3269 r3294  
    5757    public override void ResetLocalParameters(IRandom random) {
    5858      base.ResetLocalParameters(random);
    59       var normalDistributedRNG = new NormalDistributedRandom(random, Symbol.WeightNu.Value, Symbol.WeightSigma.Value);
     59      var normalDistributedRNG = new NormalDistributedRandom(random, Symbol.WeightNu, Symbol.WeightSigma);
    6060      weight = normalDistributedRNG.NextDouble();
    61       int variableIndex = random.Next(0, Symbol.VariableNames.Count);
    62       variableName = Symbol.VariableNames[variableIndex].Value;
     61      var variableList = new List<string>(Symbol.VariableNames);
     62      int variableIndex = random.Next(0, variableList.Count);
     63      variableName = variableList[variableIndex];
    6364    }
    6465
Note: See TracChangeset for help on using the changeset viewer.