/// <summary> /// Changes randomly several, but at least one, positions in the given integer <paramref name="vector"/>, according to the given probabilities. /// </summary> /// <param name="random">A random number generator.</param> /// <param name="vector">The integer vector to manipulate.</param> /// <param name="bounds"> Contains the minimum value (inclusive), maximum value (exclusive), and step size of the sampling range for /// the vector element to change.</param> /// <param name="probability">The probability for each dimension to be manipulated..</param> public static void Apply(IRandom random, IntegerVector vector, IntMatrix bounds, double probability) { if (bounds == null || bounds.Rows == 0 || bounds.Columns < 2) { throw new ArgumentException("UniformSomePositionsManipulator: Invalid bounds specified", "bounds"); } bool atLeastOneManipulated = false; for (int index = 0; index < vector.Length; index++) { if (random.NextDouble() < probability) { atLeastOneManipulated = true; UniformOnePositionManipulator.Manipulate(random, vector, bounds, index); } } if (!atLeastOneManipulated) { UniformOnePositionManipulator.Manipulate(random, vector, bounds, random.Next(vector.Length)); } }
protected UniformOnePositionManipulator(UniformOnePositionManipulator original, Cloner cloner) : base(original, cloner) { }