Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/31/11 10:59:16 (14 years ago)
Author:
mkofler
Message:

#852: Wired SwarmUpdater to update velocity vector when the scaling parameter is adjusted.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs

    r5866 r5905  
    2020#endregion
    2121
     22using System;
    2223using System.Linq;
    2324using HeuristicLab.Common;
     
    206207
    207208      Initialize();
     209      RegisterEvents();
    208210    }
    209211
     
    213215
    214216    #endregion
     217
     218    [StorableHook(HookType.AfterDeserialization)]
     219    private void RegisterEvents() {
     220      VelocityBoundsStartValueParameter.ValueChanged += new EventHandler(VelocityBoundsStartValueParameter_ValueChanged);
     221      VelocityBoundsStartValueParameter.Value.ValueChanged += new EventHandler(VelocityBoundsStartValueParameter_Value_ValueChanged);
     222    }
     223
     224    void VelocityBoundsStartValueParameter_Value_ValueChanged(object sender, EventArgs e) {
     225      if (VelocityBoundsParameter.Value == null) {
     226        VelocityBoundsParameter.Value = new DoubleMatrix(1, 2);
     227      } else if (VelocityBoundsParameter.Value.Columns != 2) {
     228        VelocityBoundsParameter.Value = new DoubleMatrix(VelocityBoundsParameter.Value.Rows, 2);
     229      }
     230      if (VelocityBoundsStartValueParameter.Value != null) {
     231        DoubleMatrix matrix = VelocityBoundsParameter.Value;
     232        for (int i = 0; i < matrix.Rows; i++) {
     233          matrix[i, 0] = (-1) * VelocityBoundsStartValueParameter.Value.Value;
     234          matrix[i, 1] = VelocityBoundsStartValueParameter.Value.Value;
     235        }
     236      }
     237    }
     238
     239    void VelocityBoundsStartValueParameter_ValueChanged(object sender, EventArgs e) {
     240      if (VelocityBoundsStartValueParameter.Value != null) {
     241        VelocityBoundsStartValueParameter.Value.ValueChanged += new EventHandler(VelocityBoundsStartValueParameter_Value_ValueChanged);
     242      }
     243    }
    215244
    216245    private void Initialize() {
     
    275304    }
    276305
    277 
    278 
    279306    private IOperation UpdateVelocityBounds() {
    280307      if (CurrentVelocityBounds == null)
     
    286313          base.Apply()
    287314        };
    288 
    289315
    290316      DoubleMatrix matrix = CurrentVelocityBounds;
Note: See TracChangeset for help on using the changeset viewer.