예제 #1
0
        void TerminationReached(object sender, EventArgs e)
        {
            _logManager.Output("Termination reached.");
            string output = "";

            var fittest = _population.BestChromosome;

            foreach (var item in ((Chromosome)fittest).ToDictionary())
            {
                output += item.Key + ": " + item.Value.ToString() + ", ";
            }

            output += string.Format("{0}: {1}", _fitness.Name, _fitness.GetValueFromFitness(fittest.Fitness));
            _logManager.Output(output);
        }
        void GenerationRan(object sender, EventArgs e)
        {
            var fittest = (Chromosome)_population.BestChromosome;

            Program.Logger.Info("Algorithm: {0}, Generation: {1}, Fitness: {2}, {3}: {4}, {5}, Id: {6}", _config.AlgorithmTypeName, _population.GenerationsNumber, fittest.Fitness,
                                _fitness.Name, _fitness.GetValueFromFitness(fittest.Fitness), fittest.ToKeyValueString(), fittest.Id);
        }
예제 #3
0
        void GenerationRan(object sender, EventArgs e)
        {
            //keep first iteration of alpha to maintain id
            if (_bestChromosome == null || _population.BestChromosome.Fitness > _bestChromosome?.Fitness)
            {
                _bestChromosome = (Chromosome)_population.BestChromosome;
            }

            Program.Logger.Info("Algorithm: {0}, Generation: {1}, Fitness: {2}, {3}: {4}, {5}, Id: {6}", _config.AlgorithmTypeName, _population.GenerationsNumber, _bestChromosome.Fitness,
                                _fitness.Name, _fitness.GetValueFromFitness(_bestChromosome.Fitness), _bestChromosome.ToKeyValueString(), _bestChromosome.Id);
        }
        public void Start()
        {
            GeneFactory.Initialize(_config.Genes);
            var chromosome = new Chromosome(false, GeneFactory.Config);

            _fitness.Evaluate(chromosome);

            LogProvider.GenerationsLogger.Info(Termination);

            var best = ((Chromosome)((SharpeMaximizer)_fitness).Best);

            var info = $"Algorithm: {_config.AlgorithmTypeName}, Fitness: {chromosome.Fitness}, {_fitness.Name}: " +
                       $"{_fitness.GetValueFromFitness(chromosome.Fitness).ToString("F")}, {best.ToKeyValueString()}";

            LogProvider.GenerationsLogger.Info(info);
        }