Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3691


Ignore:
Timestamp:
05/07/10 02:24:51 (15 years ago)
Author:
abeham
Message:

#890

  • fixed NormalAllPositionsManipulator to ignore strategy parameters if they cannot be found
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Manipulators/NormalAllPositionsManipulator.cs

    r3450 r3691  
    7575    public static void Apply(IRandom random, RealVector vector, RealVector strategyParameters) {
    7676      NormalDistributedRandom N = new NormalDistributedRandom(random, 0.0, 1.0);
    77       for (int i = 0; i < vector.Length; i++) {
    78         vector[i] = vector[i] + (N.NextDouble() * strategyParameters[i % strategyParameters.Length]);
     77      if (strategyParameters != null && strategyParameters.Length > 0) {
     78        for (int i = 0; i < vector.Length; i++) {
     79          vector[i] = vector[i] + (N.NextDouble() * strategyParameters[i % strategyParameters.Length]);
     80        }
     81      } else {
     82        for (int i = 0; i < vector.Length; i++) {
     83          vector[i] = vector[i] + N.NextDouble();
     84        }
    7985      }
    8086    }
     
    8692    /// <param name="realVector">The vector of real values that is manipulated.</param>
    8793    protected override void Manipulate(IRandom random, RealVector realVector) {
    88       if (StrategyParameterParameter.ActualValue == null) throw new InvalidOperationException("NormalAllPositionsManipulator: The strategy parameter could not be found and does not have an associated value.");
    8994      Apply(random, realVector, StrategyParameterParameter.ActualValue);
    9095    }
Note: See TracChangeset for help on using the changeset viewer.