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); }
public override double Evaluate(IChromosome chromosome) { this.Name = "DualPeriodSharpe"; var dualConfig = Clone <OptimizerConfiguration>((OptimizerConfiguration)Config); var start = Config.StartDate.Value; var end = Config.EndDate.Value; var diff = end - start; dualConfig.StartDate = end; dualConfig.EndDate = end + diff; var dualFitness = new OptimizerFitness(dualConfig, this.Filter); var first = base.Evaluate(chromosome); double second = -10; if (first > -10) { second = dualFitness.Evaluate(chromosome); } var fitness = new FitnessResult { Fitness = (first + second) / 2 }; fitness.Value = (decimal)base.GetValueFromFitness(fitness.Fitness); var output = string.Format($"Start: {Config.StartDate}, End: {Config.EndDate}, Start: {dualConfig.StartDate}, End: {dualConfig.EndDate}, " + $"Id: {((Chromosome)chromosome).Id}, Dual Period {this.Name}: {fitness.Value}"); Program.Logger.Info(output); Config.StartDate = start; Config.EndDate = end; return(fitness.Fitness); }