Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/10 15:59:37 (14 years ago)
Author:
abeham
Message:

Updated RealVector encoding to use a double matrix as bounds #929

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Creators/UniformRandomRealVectorCreator.cs

    r3060 r3123  
    4848    /// <param name="random">The random number generator.</param>
    4949    /// <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>
    5251    /// <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) {
    5653      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);
    5955      return result;
    6056    }
    6157
    6258    /// <summary>
    63     /// Forwards the call to <see cref="Apply(IRandom, int, double, double)"/>.
     59    /// Forwards the call to <see cref="Apply(IRandom, int, DoubleMatrix)"/>.
    6460    /// </summary>
    6561    /// <param name="random">The pseudo random number generator to use.</param>
    6662    /// <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>
    6964    /// <returns>The newly created real vector.</returns>
    70     protected override RealVector Create(IRandom random, IntValue length, DoubleValue 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);
    7267    }
    7368  }
Note: See TracChangeset for help on using the changeset viewer.