Changeset 17947 for branches/3107_LearningALPS/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
- Timestamp:
- 04/16/21 19:02:43 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3107_LearningALPS/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Creators/NodeImpactsReinitializationStrategyController.cs
r17917 r17947 6 6 using HeuristicLab.Common; 7 7 using HeuristicLab.Core; 8 using HeuristicLab.Data; 8 9 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 9 10 using HeuristicLab.Operators; … … 20 21 private const string ProblemDataParameterName = "ProblemData"; 21 22 private const string EstimationLimitsParameterName = "EstimationLimits"; 23 private const string MinimumFrequencyParameterName = "MinimumFrequency"; 24 private const string LearningRateParameterName = "LearningRate"; 22 25 23 26 #region Parameter Properties … … 41 44 get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; } 42 45 } 46 47 public IFixedValueParameter<DoubleValue> MinimumFrequencyParameter { 48 get { return (IFixedValueParameter<DoubleValue>)Parameters[MinimumFrequencyParameterName]; } 49 } 50 51 public IFixedValueParameter<DoubleValue> LearningRateParameter { 52 get { return (IFixedValueParameter<DoubleValue>)Parameters[LearningRateParameterName]; } 53 } 54 #endregion 55 56 #region Properties 57 public double MinimumFrequency { 58 get { return MinimumFrequencyParameter.Value.Value; } 59 set { MinimumFrequencyParameter.Value.Value = value; } 60 } 61 62 public double LearningRate { 63 get { return LearningRateParameter.Value.Value; } 64 set { LearningRateParameter.Value.Value = value; } 65 } 43 66 #endregion 44 67 … … 50 73 Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution.")); 51 74 Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic regression model.")); 75 Parameters.Add(new FixedValueParameter<DoubleValue>(MinimumFrequencyParameterName, "Minimum Frequency for the controller to set to symbols.", new DoubleValue(0))); 76 Parameters.Add(new FixedValueParameter<DoubleValue>(LearningRateParameterName, "Learning Rate for how fast the frequency is adapted. Zero learning rate means no adaption, one means new frequency = symbol frequency.", new DoubleValue(0.1))); 52 77 } 53 78 … … 62 87 [StorableHook(HookType.AfterDeserialization)] 63 88 private void AfterDeserialization() { 89 if (!Parameters.ContainsKey(MinimumFrequencyParameterName)) 90 Parameters.Add(new FixedValueParameter<DoubleValue>(MinimumFrequencyParameterName, "Minimum Frequency for the controller to set to symbols.", new DoubleValue(0))); 91 if (!Parameters.ContainsKey(LearningRateParameterName)) 92 Parameters.Add(new FixedValueParameter<DoubleValue>(LearningRateParameterName, "Learning Rate for how fast the frequency is adapted. Zero learning rate means no adaption, one means new frequency = symbol frequency.", new DoubleValue(0.1))); 64 93 } 65 94 #endregion … … 71 100 var pd = ProblemDataParameter.ActualValue; 72 101 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 102 double minimumFrequency = MinimumFrequency; 103 double learningRate = LearningRate; 73 104 74 105 if (interpreter == null) { … … 108 139 if (symbolImpacts.TryGetValue(symbol.Name, out double impact)) { 109 140 var f = Math.Max(0, impact / symbolCounts[symbol.Name]); // do something clever here 110 symbol.InitialFrequency = f; 141 double oldFrequency = symbol.InitialFrequency; 142 double impactFrequency = f; 143 double newFrequency = oldFrequency + (impactFrequency - oldFrequency) * learningRate; 144 symbol.InitialFrequency = Math.Max(minimumFrequency, newFrequency); 111 145 } 112 146 }
Note: See TracChangeset
for help on using the changeset viewer.