public static RunAlgorithm ( Dictionary list, IOptimizerConfiguration config ) : decimal>.Dictionary |
||
list | Dictionary | |
config | IOptimizerConfiguration | |
리턴 | decimal>.Dictionary |
public virtual double Evaluate(IChromosome chromosome) { try { string output = ""; var list = ((Chromosome)chromosome).ToDictionary(); list.Add("Id", ((Chromosome)chromosome).Id); foreach (var item in list) { output += item.Key + ": " + item.Value.ToString() + ", "; } if (Config.StartDate.HasValue && Config.EndDate.HasValue) { output += string.Format("Start: {0}, End: {1}, ", Config.StartDate, Config.EndDate); } var result = OptimizerAppDomainManager.RunAlgorithm(list); var fitness = CalculateFitness(result); output += string.Format("{0}: {1}", this.Name, fitness.Value); Program.Logger.Info(output); return(fitness.Fitness); } catch (Exception ex) { Program.Logger.Error(ex); return(0); } }
public virtual Dictionary <string, decimal> RunAlgorithm(Dictionary <string, object> list, IOptimizerConfiguration config) { if (config.UseSharedAppDomain) { return(SingleAppDomainManager.RunAlgorithm(list, config)); } else { return(OptimizerAppDomainManager.RunAlgorithm(list, config)); } }
public virtual double Evaluate(IChromosome chromosome) { try { string output = ""; var list = ((Chromosome)chromosome).ToDictionary(); list.Add("Id", ((Chromosome)chromosome).Id); foreach (var item in list) { output += item.Key + ": " + item.Value.ToString() + ", "; } if (Config.StartDate.HasValue && Config.EndDate.HasValue) { output += string.Format("Start: {0}, End: {1}, ", Config.StartDate, Config.EndDate); } Dictionary <string, decimal> result = null; if (Config.UseSharedAppDomain) { result = SingleAppDomainManager.RunAlgorithm(list, Config); } else { result = OptimizerAppDomainManager.RunAlgorithm(list, Config); } if (result == null) { return(0); } var fitness = CalculateFitness(result); output += string.Format("{0}: {1}", Name, fitness.Value); LogProvider.OptimizerLogger.Info(output); return(fitness.Fitness); } catch (Exception ex) { LogProvider.ErrorLogger.Error(ex); return(0); } }
//todo: configurable k-folds public override Dictionary <string, decimal> GetScore(Dictionary <string, object> list, IOptimizerConfiguration config) { //todo: threads var score = base.GetScore(list, config); var period = Config.StartDate.Value - Config.EndDate.Value.Date.AddDays(1).AddMilliseconds(-1); var oneThird = period.Ticks / 3; var oneThirdConfig = Clone((OptimizerConfiguration)Config); oneThirdConfig.EndDate = Config.StartDate.Value.AddTicks(oneThird); OptimizerAppDomainManager.RunAlgorithm(list, oneThirdConfig).Select(s => score[s.Key] += s.Value); var twoThirdsConfig = Clone((OptimizerConfiguration)Config); twoThirdsConfig.EndDate = Config.StartDate.Value.AddTicks(oneThird * 2); OptimizerAppDomainManager.RunAlgorithm(list, oneThirdConfig).Select(s => score[s.Key] += s.Value); return(score.ToDictionary(d => d.Key, d => d.Value / 3)); }
public virtual Dictionary <string, decimal> RunAlgorithm(Dictionary <string, object> list, IOptimizerConfiguration config) { return(OptimizerAppDomainManager.RunAlgorithm(list, config)); }