Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/11/12 13:37:56 (11 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/Crossovers/RoundedBlendAlphaCrossover.cs

    r8019 r8790  
    8585      var result = new IntegerVector(length);
    8686      double max = 0, min = 0, d = 0, resMin = 0, resMax = 0;
    87       int minBounds, maxBounds, step = 1;
     87      int minBound, maxBound, step = 1;
    8888
    8989      for (int i = 0; i < length; i++) {
    90         minBounds = bounds[i % bounds.Rows, 0];
    91         maxBounds = bounds[i % bounds.Rows, 1];
     90        minBound = bounds[i % bounds.Rows, 0];
     91        maxBound = bounds[i % bounds.Rows, 1];
    9292        if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2];
     93        maxBound = FloorFeasible(minBound, maxBound, step, maxBound - 1);
     94
    9395        max = Math.Max(parent1[i], parent2[i]);
    9496        min = Math.Min(parent1[i], parent2[i]);
    9597        d = Math.Abs(max - min);
    96         resMin = FloorFeasible(minBounds, maxBounds, step, min - d * alpha.Value);
    97         resMax = CeilingFeasible(minBounds, maxBounds, step, max + d * alpha.Value);
     98        resMin = FloorFeasible(minBound, maxBound, step, min - d * alpha.Value);
     99        resMax = CeilingFeasible(minBound, maxBound, step, max + d * alpha.Value);
    98100
    99         result[i] = RoundFeasible(minBounds, maxBounds, step, resMin + random.NextDouble() * Math.Abs(resMax - resMin));
     101        result[i] = RoundFeasible(minBound, maxBound, step, resMin + random.NextDouble() * Math.Abs(resMax - resMin));
    100102      }
    101103      return result;
Note: See TracChangeset for help on using the changeset viewer.