Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/19/20 15:01:59 (4 years ago)
Author:
abeham
Message:

#2521: Introduce class to make parameter change handling easier, fix bug in SingleObjectiveProblem regarding MaximizationChanged

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Binary/3.3/DeceptiveStepTrapProblem.cs

    r17544 r17546  
    2222#endregion
    2323
    24 using System;
    2524using HEAL.Attic;
    2625using HeuristicLab.Common;
     
    4544    public DeceptiveStepTrapProblem() : base() {
    4645      Parameters.Add(StepSizeParameter = new FixedValueParameter<IntValue>("Step Size", "", new IntValue(2)));
    47       offset = (TrapSize - StepSize) % StepSize;
     46      CalculateOffset();
    4847
    4948      RegisterParameterEvents();
     
    7978
    8079    private void RegisterParameterEvents() {
    81       StepSizeParameter.Value.ValueChanged += StepSizeOnChanged;
     80      IntValueParameterChangeHandler.Create(StepSizeParameter, CalculateOffset);
    8281    }
    8382
    84     protected override void TrapSizeOnChanged(object sender, EventArgs e) {
    85       base.TrapSizeOnChanged(sender, e);
    86       offset = (TrapSize - StepSize) % StepSize;
     83    protected override void TrapSizeOnChanged() {
     84      base.TrapSizeOnChanged();
     85      CalculateOffset();
    8786    }
    8887
    89     private void StepSizeOnChanged(object sender, EventArgs e) {
     88    private void CalculateOffset() {
    9089      offset = (TrapSize - StepSize) % StepSize;
    9190    }
Note: See TracChangeset for help on using the changeset viewer.