- Timestamp:
- 10/11/12 13:37:56 (12 years ago)
- 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 67 67 int min = bounds[i % bounds.Rows, 0], max = bounds[i % bounds.Rows, 1], step = 1; 68 68 if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2]; 69 max = FloorFeasible(min, max, step, max - 1); 69 70 result[i] = RoundFeasible(min, max, step, avg); 70 71 } -
trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Crossovers/RoundedBlendAlphaBetaCrossover.cs
r8019 r8790 105 105 if (beta.Value < 0) throw new ArgumentException("RoundedBlendAlphaBetaCrossover: Parameter beta must be greater or equal to 0.", "beta"); 106 106 if (bounds == null || bounds.Rows < 1 || bounds.Columns < 2) throw new ArgumentException("RoundedBlendAlphaBetaCrossover: Invalid bounds specified.", "bounds"); 107 107 108 108 int length = betterParent.Length; 109 109 double min, max, d; … … 114 114 maxBound = bounds[i % bounds.Rows, 1]; 115 115 if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2]; 116 maxBound = FloorFeasible(minBound, maxBound, step, maxBound - 1); 116 117 117 118 d = Math.Abs(betterParent[i] - worseParent[i]); -
trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Crossovers/RoundedBlendAlphaCrossover.cs
r8019 r8790 85 85 var result = new IntegerVector(length); 86 86 double max = 0, min = 0, d = 0, resMin = 0, resMax = 0; 87 int minBound s, maxBounds, step = 1;87 int minBound, maxBound, step = 1; 88 88 89 89 for (int i = 0; i < length; i++) { 90 minBound s= bounds[i % bounds.Rows, 0];91 maxBound s= bounds[i % bounds.Rows, 1];90 minBound = bounds[i % bounds.Rows, 0]; 91 maxBound = bounds[i % bounds.Rows, 1]; 92 92 if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2]; 93 maxBound = FloorFeasible(minBound, maxBound, step, maxBound - 1); 94 93 95 max = Math.Max(parent1[i], parent2[i]); 94 96 min = Math.Min(parent1[i], parent2[i]); 95 97 d = Math.Abs(max - min); 96 resMin = FloorFeasible(minBound s, maxBounds, step, min - d * alpha.Value);97 resMax = CeilingFeasible(minBound s, 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); 98 100 99 result[i] = RoundFeasible(minBound s, maxBounds, step, resMin + random.NextDouble() * Math.Abs(resMax - resMin));101 result[i] = RoundFeasible(minBound, maxBound, step, resMin + random.NextDouble() * Math.Abs(resMax - resMin)); 100 102 } 101 103 return result; -
trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Crossovers/RoundedHeuristicCrossover.cs
r8019 r8790 88 88 max = bounds[i % bounds.Rows, 1]; 89 89 if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2]; 90 max = FloorFeasible(min, max, step, max - 1); 90 91 result[i] = RoundFeasible(min, max, step, betterParent[i] + factor * (betterParent[i] - worseParent[i])); 91 92 } -
trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Crossovers/RoundedLocalCrossover.cs
r8019 r8790 64 64 max = bounds[i % bounds.Rows, 1]; 65 65 if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2]; 66 max = FloorFeasible(min, max, step, max - 1); 66 67 factor = random.NextDouble(); 67 68 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 85 85 int min = bounds[i % bounds.Rows, 0], max = bounds[i % bounds.Rows, 1], step = 1; 86 86 if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2]; 87 max = FloorFeasible(min, max, step, max - 1); 87 88 double value = alpha.Value * parent1[i] + (1 - alpha.Value) * parent2[i]; 88 89 result[i] = RoundFeasible(min, max, step, value); -
trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Manipulators/RoundedNormalAllPositionsManipulator.cs
r8019 r8790 76 76 77 77 int value = (vector[i] + (int)Math.Round((N.NextDouble() * sigma[i % sigma.Length])) - min) / step; 78 max = FloorFeasible(min, max, step, max - 1); 78 79 vector[i] = RoundFeasible(min, max, step, value); 79 80 } -
trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Manipulators/SelfAdaptiveRoundedNormalAllPositionsManipulator.cs
r8019 r8790 86 86 87 87 int value = (vector[i] + (int)Math.Round((N.NextDouble() * strategyParameters[i % strategyParameters.Length])) - min) / step; 88 max = FloorFeasible(min, max, step, max - 1); 88 89 vector[i] = RoundFeasible(min, max, step, value); 89 90 } -
trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Manipulators/UniformOnePositionManipulator.cs
r8019 r8790 85 85 if (bounds == null || bounds.Rows == 0 || bounds.Columns < 2) throw new ArgumentException("UniformOnePositionManipulator: Invalid bounds specified", "bounds"); 86 86 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 } 89 97 } 90 98
Note: See TracChangeset
for help on using the changeset viewer.