Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/11/12 13:37:56 (12 years ago)
Author:
abeham
Message:

#1969: Made sure max is exclusive and always a feasible value (a multiple of step + min)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Manipulators/UniformOnePositionManipulator.cs

    r8019 r8790  
    8585      if (bounds == null || bounds.Rows == 0 || bounds.Columns < 2) throw new ArgumentException("UniformOnePositionManipulator: Invalid bounds specified", "bounds");
    8686      int min = bounds[index % bounds.Rows, 0], max = bounds[index % bounds.Rows, 1], step = 1;
    87       if (bounds.Columns > 2) step = bounds[index % bounds.Rows, 2];
    88       vector[index] = RoundFeasible(min, max, step, random.Next(min, max + 1));
     87      if (min == max) {
     88        vector[index] = min;
     89      } else {
     90        if (bounds.Columns > 2) step = bounds[index % bounds.Rows, 2];
     91        // max has to be rounded to the lower feasible value
     92        // e.g. min...max / step = 0...100 / 5, max is exclusive so it would be 0..99
     93        // but 99 is not a feasible value, so max needs to be adjusted => min = 0, max = 95
     94        max = FloorFeasible(min, max, step, max - 1);
     95        vector[index] = RoundFeasible(min, max, step, random.Next(min, max));
     96      }
    8997    }
    9098
Note: See TracChangeset for help on using the changeset viewer.