- Timestamp:
- 04/05/10 18:52:23 (15 years ago)
- 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
r3258 r3269 21 21 22 22 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 23 using HeuristicLab.Core; 24 using HeuristicLab.Operators; 25 using HeuristicLab.Random; 26 using HeuristicLab.Data; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Parameters; 23 29 namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Symbols { 30 [StorableClass] 31 [Item("Constant", "Represents a constant value.")] 24 32 public sealed class Constant : Symbol { 33 #region Parameter Properties 34 public IValueParameter<DoubleValue> MinValueParameter { 35 get { return (IValueParameter<DoubleValue>)Parameters["MinValue"]; } 36 } 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; } 49 } 50 #endregion 51 public Constant() 52 : 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))); 55 } 56 25 57 public override SymbolicExpressionTreeNode CreateTreeNode() { 26 58 return new ConstantTreeNode(this); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Symbols/ConstantTreeNode.cs
r3258 r3269 24 24 using System.Collections.Generic; 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 28 using HeuristicLab.Random; 26 29 namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Symbols { 27 30 [StorableClass] 28 31 public sealed class ConstantTreeNode : SymbolicExpressionTreeTerminalNode { 32 public new Constant Symbol { 33 get { return (Constant)base.Symbol; } 34 } 29 35 public override bool HasLocalParameters { 30 36 get { … … 39 45 set { constantValue = value; } 40 46 } 41 42 47 // copy constructor 43 48 private ConstantTreeNode(ConstantTreeNode original) … … 48 53 public ConstantTreeNode(Constant constantSymbol) : base(constantSymbol) { } 49 54 55 public override void ResetLocalParameters(IRandom random) { 56 base.ResetLocalParameters(random); 57 var range = Symbol.MaxValue.Value - Symbol.MaxValue.Value; 58 Value = random.NextDouble() * range - Symbol.MinValue.Value; 59 } 60 50 61 public override object Clone() { 51 62 return new ConstantTreeNode(this); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Symbols/Variable.cs
r3258 r3269 21 21 22 22 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 23 using HeuristicLab.Core; 24 using HeuristicLab.Operators; 25 using HeuristicLab.Random; 26 using HeuristicLab.Data; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Parameters; 23 29 namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Symbols { 30 [StorableClass] 31 [Item("Variable", "Represents a variable value.")] 24 32 public sealed class Variable : Symbol { 33 #region Parameter Properties 34 public IValueParameter<DoubleValue> WeightNuParameter { 35 get { return (IValueParameter<DoubleValue>)Parameters["WeightNu"]; } 36 } 37 public IValueParameter<DoubleValue> WeightSigmaParameter { 38 get { return (IValueParameter<DoubleValue>)Parameters["WeightSigma"]; } 39 } 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; } 56 } 57 #endregion 58 public Variable() 59 : 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.")); 63 } 64 25 65 public override SymbolicExpressionTreeNode CreateTreeNode() { 26 66 return new VariableTreeNode(this); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Symbols/VariableTreeNode.cs
r3258 r3269 24 24 using System.Collections.Generic; 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 28 using HeuristicLab.Random; 26 29 namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Symbols { 27 30 [StorableClass] 28 31 public sealed class VariableTreeNode : SymbolicExpressionTreeTerminalNode { 29 32 public new Variable Symbol { 33 get { return (Variable)base.Symbol; } 34 } 30 35 private double weight; 31 36 [Storable] … … 50 55 public VariableTreeNode(Variable variableSymbol) : base(variableSymbol) { } 51 56 57 public override void ResetLocalParameters(IRandom random) { 58 base.ResetLocalParameters(random); 59 var normalDistributedRNG = new NormalDistributedRandom(random, Symbol.WeightNu.Value, Symbol.WeightSigma.Value); 60 weight = normalDistributedRNG.NextDouble(); 61 int variableIndex = random.Next(0, Symbol.VariableNames.Count); 62 variableName = Symbol.VariableNames[variableIndex].Value; 63 } 64 52 65 public override object Clone() { 53 66 return new VariableTreeNode(this);
Note: See TracChangeset
for help on using the changeset viewer.