- Timestamp:
- 03/19/10 15:59:37 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Creators/UniformRandomRealVectorCreator.cs
r3060 r3123 48 48 /// <param name="random">The random number generator.</param> 49 49 /// <param name="length">The length of the real vector.</param> 50 /// <param name="min">The minimum value of the sampling range for each vector element (inclusive).</param> 51 /// <param name="max">The maximum value of the sampling range for each vector element (exclusive).</param> 50 /// <param name="bounds">The lower and upper bound (1st and 2nd column) of the positions in the vector. If there are less rows than dimensions, the rows are cycled.</param> 52 51 /// <returns>The newly created real vector.</returns> 53 public static RealVector Apply(IRandom random, int length, double min, double max) { 54 if (length <= 0) throw new ArgumentException("UniformRandomRealVectorCreator: Length is smaller or equal to 0.", "length"); 55 if (min > max) throw new ArgumentException("UniformRandomRealVectorCreator: Minimum is greater than Maximum.", "min"); 52 public static RealVector Apply(IRandom random, int length, DoubleMatrix bounds) { 56 53 RealVector result = new RealVector(length); 57 for (int i = 0; i < length; i++) 58 result[i] = min + random.NextDouble() * (max - min); 54 result.Randomize(random, bounds); 59 55 return result; 60 56 } 61 57 62 58 /// <summary> 63 /// Forwards the call to <see cref="Apply(IRandom, int, double, double)"/>.59 /// Forwards the call to <see cref="Apply(IRandom, int, DoubleMatrix)"/>. 64 60 /// </summary> 65 61 /// <param name="random">The pseudo random number generator to use.</param> 66 62 /// <param name="length">The length of the real vector.</param> 67 /// <param name="minimum">The minimum value of the sampling range for each vector element (inclusive).</param> 68 /// <param name="maximum">The maximum value of the sampling range for each vector element (exclusive).</param> 63 /// <param name="bounds">The lower and upper bound (1st and 2nd column) of the positions in the vector. If there are less rows than dimensions, the rows are cycled.</param> 69 64 /// <returns>The newly created real vector.</returns> 70 protected override RealVector Create(IRandom random, IntValue length, Double Value minimum, DoubleValue maximum) {71 return Apply(random, length.Value, minimum.Value, maximum.Value);65 protected override RealVector Create(IRandom random, IntValue length, DoubleMatrix bounds) { 66 return Apply(random, length.Value, bounds); 72 67 } 73 68 }
Note: See TracChangeset
for help on using the changeset viewer.