Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/28/18 16:56:41 (6 years ago)
Author:
bburlacu
Message:

#2886: address additional serialization issues, make Production implement IList<T> instead of deriving from List<T>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs

    r15974 r15975  
    5252    }
    5353
    54     protected double VariableImportanceWeight {
     54    public double VariableImportanceWeight {
    5555      get { return VariableImportanceWeightParameter.Value.Value; }
     56      set { VariableImportanceWeightParameter.Value.Value = value; }
    5657    }
    5758
     
    133134    }
    134135
     136    [Storable]
    135137    public SymbolString BestTrainingSentence { get; set; }     // Currently set in RSquaredEvaluator: quite hacky, but makes testing much easier for now...
    136138    #endregion
     
    144146    [Storable]
    145147    internal SearchDataStore OpenPhrases { get; private set; }           // Stack/Queue/etc. for fetching the next node in the search tree. 
    146 
    147     [StorableHook(HookType.AfterDeserialization)]
    148     private void AfterDeserialization() {
    149       variableImportance = CalculateVariableImportances();
    150     }
    151148
    152149    #region execution stats
     
    162159    #endregion
    163160
     161    [Storable]
    164162    public Grammar Grammar { get; private set; }
    165163
     
    168166      return new GrammarEnumerationAlgorithm(this, cloner);
    169167    }
     168
     169    [StorableConstructor]
     170    protected GrammarEnumerationAlgorithm(bool deserializing) : base(deserializing) { }
    170171
    171172    public GrammarEnumerationAlgorithm() {
     
    237238    #endregion
    238239
     240    [Storable]
    239241    private Dictionary<VariableTerminalSymbol, double> variableImportance;
    240242
     
    250252      OpenPhrases = new SearchDataStore(SearchDataStructure, SearchDataStructureSize, SearchCacheSize); // Select search strategy
    251253
     254      CalculateVariableImportances();
     255
    252256      base.Prepare(); // this actually clears the results which will get reinitialized on Run()
    253257    }
    254258
    255     private Dictionary<VariableTerminalSymbol, double> CalculateVariableImportances() {
     259    private void CalculateVariableImportances() {
    256260      variableImportance = new Dictionary<VariableTerminalSymbol, double>();
    257261
     
    271275        variableImportance[varSym] = rfImpact.Item2 / sum;
    272276      }
    273       return variableImportance;
    274277    }
    275278
     
    277280      // do not reinitialize the algorithm if we're resuming from pause
    278281      if (previousExecutionState != ExecutionState.Paused) {
    279         CalculateVariableImportances();
    280282        InitResults();
    281283        var phrase0 = new SymbolString(new[] { Grammar.StartSymbol });
Note: See TracChangeset for help on using the changeset viewer.