Changeset 7681 for branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVector.cs
- Timestamp:
- 04/02/12 00:29:39 (12 years ago)
- Location:
- branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVector.cs
r7259 r7681 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 49 50 } 50 51 51 public virtual void Randomize(IRandom random, int startIndex, int length, int min, int max ) {52 public virtual void Randomize(IRandom random, int startIndex, int length, int min, int max, int step = 1) { 52 53 if (length > 0) { 53 for (int i = 0; i < length; i++) 54 array[startIndex + i] = random.Next(min, max); 54 int numbers = (int)Math.Floor((max - min) / (double)step); 55 for (int i = startIndex; i < startIndex + length; i++) { 56 array[i] = random.Next(numbers) * step + min; 57 } 55 58 OnReset(); 56 59 } 57 60 } 58 public void Randomize(IRandom random, int min, int max) { 59 Randomize(random, 0, Length, min, max); 61 public virtual void Randomize(IRandom random, int startIndex, int length, IntMatrix bounds) { 62 if (length > 0) { 63 for (int i = startIndex; i < startIndex + length; i++) { 64 int min = bounds[i % bounds.Rows, 0], max = bounds[i % bounds.Rows, 1], step = 1; 65 if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2]; 66 int numbers = (int)Math.Floor((max - min) / (double)step); 67 array[i] = random.Next(numbers) * step + min; 68 } 69 OnReset(); 70 } 71 } 72 public void Randomize(IRandom random, int min, int max, int step = 1) { 73 Randomize(random, 0, Length, min, max, step); 74 } 75 public void Randomize(IRandom random, IntMatrix bounds) { 76 Randomize(random, 0, Length, bounds); 60 77 } 61 78 }
Note: See TracChangeset
for help on using the changeset viewer.