Changeset 18182


Ignore:
Timestamp:
01/11/22 09:50:15 (10 days ago)
Author:
dpiringe
Message:

#3136

  • fixed missing/wrong event registration for SubFunction and StructuredSymbolicRegressionSingleObjectiveProblem
Location:
branches/3136_Structural_GP
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/StructuredSymbolicRegressionSingleObjectiveProblem.cs

    r18178 r18182  
    129129    public StructuredSymbolicRegressionSingleObjectiveProblem(StructuredSymbolicRegressionSingleObjectiveProblem original,
    130130      Cloner cloner) : base(original, cloner) {
    131       ProblemDataParameter.ValueChanged += ProblemDataParameterValueChanged;
    132131      RegisterEventHandlers();
    133132    }
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/SubFunction.cs

    r18164 r18182  
    5555      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, new IntValue(8)));
    5656      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, new IntValue(20)));
    57 
    58       GrammarParameter.ValueChanged += OnParameterValueChanged;
    59       MaximumSymbolicExpressionTreeDepthParameter.Value.ValueChanged += OnParameterValueChanged;
    60       MaximumSymbolicExpressionTreeLengthParameter.Value.ValueChanged += OnParameterValueChanged;
     57      RegisterEventHandlers();
    6158    }
    62 
    63     private void OnParameterValueChanged(object sender, EventArgs e) => Changed?.Invoke(this, EventArgs.Empty);
    6459
    6560    protected SubFunction(SubFunction original, Cloner cloner) : base(original, cloner) {
    6661      Arguments = original.Arguments;
     62      RegisterEventHandlers();
    6763    }
    6864
    6965    [StorableConstructor]
    70     protected SubFunction(StorableConstructorFlag _) : base(_) {}
     66    protected SubFunction(StorableConstructorFlag _) : base(_) { }
     67
     68
     69    [StorableHook(HookType.AfterDeserialization)]
     70    private void AfterDeserialization() {
     71      RegisterEventHandlers();
     72    }
    7173    #endregion
    7274
     
    7577      new SubFunction(this, cloner);
    7678    #endregion
     79
     80    #region Event Handling
     81    private void RegisterEventHandlers() {
     82      GrammarParameter.ValueChanged += OnParameterValueChanged;
     83      MaximumSymbolicExpressionTreeDepthParameter.Value.ValueChanged += OnParameterValueChanged;
     84      MaximumSymbolicExpressionTreeLengthParameter.Value.ValueChanged += OnParameterValueChanged;
     85    }
     86
     87    private void OnParameterValueChanged(object sender, EventArgs e) =>
     88      Changed?.Invoke(this, EventArgs.Empty);
     89    #endregion
     90
    7791
    7892    public override string ToString() => $"{Name}({string.Join(",", Arguments)})";
Note: See TracChangeset for help on using the changeset viewer.