Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/21 19:02:43 (4 years ago)
Author:
pfleck
Message:

#3107 Added MinimumFrequency and LearningRate parameters to symbol frequency and node impact strategy controllers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3107_LearningALPS/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Creators/NodeImpactsReinitializationStrategyController.cs

    r17917 r17947  
    66using HeuristicLab.Common;
    77using HeuristicLab.Core;
     8using HeuristicLab.Data;
    89using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    910using HeuristicLab.Operators;
     
    2021    private const string ProblemDataParameterName = "ProblemData";
    2122    private const string EstimationLimitsParameterName = "EstimationLimits";
     23    private const string MinimumFrequencyParameterName = "MinimumFrequency";
     24    private const string LearningRateParameterName = "LearningRate";
    2225
    2326    #region Parameter Properties
     
    4144      get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; }
    4245    }
     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    }
    4366    #endregion
    4467
     
    5073      Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution."));
    5174      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)));
    5277    }
    5378
     
    6287    [StorableHook(HookType.AfterDeserialization)]
    6388    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)));
    6493    }
    6594    #endregion
     
    71100      var pd = ProblemDataParameter.ActualValue;
    72101      var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
     102      double minimumFrequency = MinimumFrequency;
     103      double learningRate = LearningRate;
    73104
    74105      if (interpreter == null) {
     
    108139        if (symbolImpacts.TryGetValue(symbol.Name, out double impact)) {
    109140          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);
    111145        }
    112146      }
Note: See TracChangeset for help on using the changeset viewer.