Changeset 17857
- Timestamp:
- 03/03/21 13:33:41 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3107_LearningALPS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Creators/SymbolFrequencyReinitializationStrategyController.cs
r17854 r17857 1 using HEAL.Attic; 1 using System.Linq; 2 3 using HEAL.Attic; 2 4 using HeuristicLab.Common; 3 5 using HeuristicLab.Core; 4 6 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 5 7 using HeuristicLab.Operators; 8 using HeuristicLab.Optimization; 6 9 using HeuristicLab.Parameters; 7 10 … … 9 12 [Item("SymbolFrequencyReinitializationStrategyController", "")] 10 13 [StorableType("8F0B7020-A02F-491D-881A-5CE550426E5B")] 11 public class SymbolFrequencyReinitializationStrategyController : InstrumentedOperator {14 public class SymbolFrequencyReinitializationStrategyController : InstrumentedOperator, IReinitializationStrategyController { 12 15 13 16 private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree"; … … 24 27 #endregion 25 28 26 #region Constructo s29 #region Constructors 27 30 public SymbolFrequencyReinitializationStrategyController() { 28 31 Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree whose length should be calculated.")); … … 48 51 var grammar = SymbolicExpressionTreeGrammarParameter.ActualValue; 49 52 50 var symbolFrequencies = SymbolicExpressionSymbolFrequencyAnalyzer.CalculateSymbolFrequencies(trees); 51 // TODO: adapt grammar 53 var symbolFrequencies = SymbolicExpressionSymbolFrequencyAnalyzer.CalculateSymbolFrequencies(trees).ToDictionary(x => x.Key, x => x.Value); 54 55 foreach(var s in grammar.AllowedSymbols) { 56 if (s is ProgramRootSymbol || s is StartSymbol) { 57 continue; 58 } 59 60 if (symbolFrequencies.TryGetValue(s.Name, out double f)) { 61 s.InitialFrequency = f; 62 } 63 } 52 64 53 65 return base.InstrumentedApply();
Note: See TracChangeset
for help on using the changeset viewer.