Exemplo n.º 1
0
        public static KeyValuePair <int, T> GetRandomElementWithIndex <T>(this ICollection <T> collection)
        {
            var randomIndex   = RandomFactory.GetInstance().Next(collection.Count);
            var randomElement = collection.ElementAtOrDefault(randomIndex);

            return(new KeyValuePair <int, T>(randomIndex, randomElement));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of <see cref="DynamicParameterProvider"/>
        /// </summary>
        /// <param name="parameterSetListCapacity">Parameter set list capacity</param>
        public DynamicParameterProvider(int parameterSetListCapacity)
        {
            _random = RandomFactory.GetInstance();
            _currentParameterSetIndex = 0;

            ParameterSets        = GenerateRandomParameters(parameterSetListCapacity);
            WinningParameterSets = new List <Tuple <double, double> >();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseHarmonyGenerator{T}"/> class.
        /// </summary>
        /// <param name="function">The function.</param>
        /// <exception cref="ArgumentNullException">function</exception>
        protected BaseHarmonyGenerator(IObjectiveFunction <T> function)
        {
            ObjectiveFunction = function ?? throw new ArgumentNullException(nameof(function));

            Random = RandomFactory.GetInstance();
        }
Exemplo n.º 4
0
        public static T GetRandomElement <T>(this ICollection <T> collection)
        {
            var randomIndex = RandomFactory.GetInstance().Next(collection.Count);

            return(collection.ElementAtOrDefault(randomIndex));
        }
Exemplo n.º 5
0
 public static int GetRandomIndexMinimum <T>(this ICollection <T> collection, int startIndex)
 {
     return(RandomFactory.GetInstance().Next(startIndex, collection.Count));
 }
Exemplo n.º 6
0
 public static int GetRandomIndex <T>(this ICollection <T> collection)
 {
     return(RandomFactory.GetInstance().Next(collection.Count));
 }