Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/17/17 16:26:58 (7 years ago)
Author:
abeham
Message:

#2457: added event handling to FLA Characterizer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3/Algorithms/FLACharacterizer.cs

    r15331 r15332  
    3939    }
    4040
     41    public ICharacteristicCalculator Calculator {
     42      get { return CalculatorParameter.Value; }
     43    }
     44
    4145    [StorableConstructor]
    4246    private FLACharacterizer(bool deserializing) : base(deserializing) { }
    43     private FLACharacterizer(FLACharacterizer original, Cloner cloner) : base(original, cloner) { }
     47    private FLACharacterizer(FLACharacterizer original, Cloner cloner)
     48      : base(original, cloner) {
     49      RegisterEventHandlers();
     50    }
    4451    public FLACharacterizer() : base() {
    4552      Parameters.Add(new ValueParameter<ICharacteristicCalculator>("Calculator", "The FLA characteristic calculator.", new RandomWalkCalculator()));
     53      RegisterEventHandlers();
    4654    }
    4755
     
    4957      return new FLACharacterizer(this, cloner);
    5058    }
     59   
     60    [StorableHook(HookType.AfterDeserialization)]
     61    private void AfterDeserialization() {
     62      RegisterEventHandlers();
     63    }
     64
     65    private void RegisterEventHandlers() {
     66      CalculatorParameter.ValueChanged += CalculatorParameterOnValueChanged;
     67    }
     68
     69    private void CalculatorParameterOnValueChanged(object sender, EventArgs e) {
     70      Calculator.Problem = Problem;
     71    }
     72
     73    protected override void OnProblemChanged() {
     74      base.OnProblemChanged();
     75      Calculator.Problem = Problem;
     76    }
    5177
    5278    protected override void Run(CancellationToken cancellationToken) {
    53       var calculator = CalculatorParameter.Value;
    54       calculator.Problem = Problem;
     79      var calculator = Calculator;
    5580      if (calculator.CanCalculate()) {
    5681        foreach (var result in calculator.Calculate()) {
Note: See TracChangeset for help on using the changeset viewer.