Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15979


Ignore:
Timestamp:
07/03/18 10:55:29 (6 years ago)
Author:
bburlacu
Message:

#2886: Register algorithm events after deserialization.

File:
1 edited

Legend:

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

    r15977 r15979  
    170170    protected GrammarEnumerationAlgorithm(bool deserializing) : base(deserializing) { }
    171171
     172    private void RegisterEvents() {
     173      // re-wire analyzer events
     174      foreach (var analyzer in Analyzers.CheckedItems)
     175        analyzer.Register(this);
     176      Analyzers.CheckedItemsChanged += Analyzers_CheckedItemsChanged;
     177
     178      SearchDataStructureParameter.Value.ValueChanged += (o, e) => Prepare();
     179      SearchDataStructureSizeParameter.Value.ValueChanged += (o, e) => Prepare();
     180      SearchCacheSizeParameter.Value.ValueChanged += (o, e) => Prepare();
     181    }
     182
     183    private void DeregisterEvents() {
     184      foreach (var analyzer in Analyzers.CheckedItems)
     185        analyzer.Register(this);
     186      Analyzers.CheckedItemsChanged -= Analyzers_CheckedItemsChanged;
     187
     188      SearchDataStructureParameter.Value.ValueChanged -= (o, e) => Prepare();
     189      SearchDataStructureSizeParameter.Value.ValueChanged -= (o, e) => Prepare();
     190      SearchCacheSizeParameter.Value.ValueChanged -= (o, e) => Prepare();
     191    }
     192
     193    [StorableHook(HookType.AfterDeserialization)]
     194    private void AfterDeserialization() {
     195      RegisterEvents();
     196    }
     197
    172198    public GrammarEnumerationAlgorithm() {
    173199      Parameters.Add(new FixedValueParameter<DoubleValue>(VariableImportanceWeightName, "Variable Weight.", new DoubleValue(1.0)));
     
    417443    #region pause support
    418444    private ExecutionState previousExecutionState;
     445
    419446    protected override void OnPaused() {
    420447      previousExecutionState = this.ExecutionState;
    421448      base.OnPaused();
    422449    }
     450
    423451    protected override void OnPrepared() {
    424452      previousExecutionState = this.ExecutionState;
    425453      base.OnPrepared();
    426454    }
     455
    427456    protected override void OnStarted() {
    428457      previousExecutionState = this.ExecutionState;
    429458      base.OnStarted();
    430459    }
     460
    431461    protected override void OnStopped() {
    432462      previousExecutionState = this.ExecutionState;
Note: See TracChangeset for help on using the changeset viewer.