Ejemplo n.º 1
0
        /// <summary>
        ///     Initialize the process, by creating the initial population using the configured provider.
        /// </summary>
        /// <exception cref="InvalidOperationException"></exception>
        // ReSharper disable always PossibleNullReferenceException
        public void Initialize()
        {
            #region Validation

            if (_population != null)
            {
                throw new InvalidOperationException("Already initialized");
            }
            if (_populationInitializer == null)
            {
                throw new InvalidOperationException($"{nameof(_populationInitializer)} not set");
            }
            if (!_initialPopulationSize.HasValue)
            {
                throw new InvalidOperationException($"{nameof(_initialPopulationSize)} not set");
            }

            #endregion

            LogInfo("Initializing population");
            _population = _populationInitializer.InitializePopulation(_initialPopulationSize.Value);

            LogInfo("Initializing calculating initial fitnesses");
            _population.OrderByFitness(_fitnessFunction);
        }
Ejemplo n.º 2
0
        private List <Individual> InitializeIndividuals()
        {
            var individuals = _populationInitialiser.InitializePopulation(_config.PopulationSize);

            return(individuals);
        }