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)

Location:
trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Crossovers/RoundedAverageCrossover.cs

    r8019 r8790  
    6767          int min = bounds[i % bounds.Rows, 0], max = bounds[i % bounds.Rows, 1], step = 1;
    6868          if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2];
     69          max = FloorFeasible(min, max, step, max - 1);
    6970          result[i] = RoundFeasible(min, max, step, avg);
    7071        }
  • trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Crossovers/RoundedBlendAlphaBetaCrossover.cs

    r8019 r8790  
    105105      if (beta.Value < 0) throw new ArgumentException("RoundedBlendAlphaBetaCrossover: Parameter beta must be greater or equal to 0.", "beta");
    106106      if (bounds == null || bounds.Rows < 1 || bounds.Columns < 2) throw new ArgumentException("RoundedBlendAlphaBetaCrossover: Invalid bounds specified.", "bounds");
    107      
     107
    108108      int length = betterParent.Length;
    109109      double min, max, d;
     
    114114        maxBound = bounds[i % bounds.Rows, 1];
    115115        if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2];
     116        maxBound = FloorFeasible(minBound, maxBound, step, maxBound - 1);
    116117
    117118        d = Math.Abs(betterParent[i] - worseParent[i]);
  • 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;
  • trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Crossovers/RoundedHeuristicCrossover.cs

    r8019 r8790  
    8888        max = bounds[i % bounds.Rows, 1];
    8989        if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2];
     90        max = FloorFeasible(min, max, step, max - 1);
    9091        result[i] = RoundFeasible(min, max, step, betterParent[i] + factor * (betterParent[i] - worseParent[i]));
    9192      }
  • trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Crossovers/RoundedLocalCrossover.cs

    r8019 r8790  
    6464        max = bounds[i % bounds.Rows, 1];
    6565        if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2];
     66        max = FloorFeasible(min, max, step, max - 1);
    6667        factor = random.NextDouble();
    6768        result[i] = RoundFeasible(min, max, step, (factor * parent1[i]) + ((1 - factor) * parent2[i]));
  • trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Crossovers/RoundedUniformArithmeticCrossover.cs

    r8019 r8790  
    8585          int min = bounds[i % bounds.Rows, 0], max = bounds[i % bounds.Rows, 1], step = 1;
    8686          if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2];
     87          max = FloorFeasible(min, max, step, max - 1);
    8788          double value = alpha.Value * parent1[i] + (1 - alpha.Value) * parent2[i];
    8889          result[i] = RoundFeasible(min, max, step, value);
  • trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Manipulators/RoundedNormalAllPositionsManipulator.cs

    r8019 r8790  
    7676
    7777        int value = (vector[i] + (int)Math.Round((N.NextDouble() * sigma[i % sigma.Length])) - min) / step;
     78        max = FloorFeasible(min, max, step, max - 1);
    7879        vector[i] = RoundFeasible(min, max, step, value);
    7980      }
  • trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Manipulators/SelfAdaptiveRoundedNormalAllPositionsManipulator.cs

    r8019 r8790  
    8686
    8787          int value = (vector[i] + (int)Math.Round((N.NextDouble() * strategyParameters[i % strategyParameters.Length])) - min) / step;
     88          max = FloorFeasible(min, max, step, max - 1);
    8889          vector[i] = RoundFeasible(min, max, step, value);
    8990        }
  • 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.