public static async Task Main(string[] args) { Console.WriteLine($"[{DateTime.Now}] Tuner start"); SettingsLoader.Init("settings.json"); _webService = new WebService(); _generationStopwatch = new Stopwatch(); await _webService.EnableIfAvailable(); _testId = await _webService.RegisterTest(); var selection = new EliteSelection(); var crossover = new UniformCrossover(0.5f); var mutation = new UniformMutation(true); var fitness = new EvaluationFitness(_testId, _webService); var chromosome = new EvaluationChromosome(); var population = new Population(SettingsLoader.Data.MinPopulation, SettingsLoader.Data.MaxPopulation, chromosome); var geneticAlgorithm = new GeneticAlgorithm(population, fitness, selection, crossover, mutation); geneticAlgorithm.Termination = new GenerationNumberTermination(SettingsLoader.Data.GenerationsCount); geneticAlgorithm.GenerationRan += GeneticAlgorithm_GenerationRan; _generationStopwatch.Start(); geneticAlgorithm.Start(); Console.WriteLine("Best solution found has {0} fitness.", geneticAlgorithm.BestChromosome.Fitness); Console.ReadLine(); }
static async Task Main(string[] args) { Console.WriteLine($"[{DateTime.Now}] Tuner start"); SettingsLoader.Init("settings.json"); IFitness fitness = null; IChromosome chromosome = null; _webService = new WebService(); await _webService.EnableIfAvailable(); _testId = await _webService.RegisterTest(new RegisterTestRequest { Type = TestType.Texel }); var scalingFactorMode = args.Contains("scaling_factor"); if (scalingFactorMode) { SettingsLoader.Data.Genes.Clear(); SettingsLoader.Data.Genes.Add(new GeneInfo { Name = "ScalingFactor", MinValue = 0, MaxValue = 2000 }); SettingsLoader.Data.Genes.Add(new GeneInfo { Name = "Unused", MinValue = 0, MaxValue = 1 }); fitness = new ScalingFactorFitness(_testId, _webService); chromosome = new ScalingFactorChromosome(); } else { fitness = new EvaluationFitness(_testId, _webService); chromosome = new EvaluationChromosome(); } var selection = new EliteSelection(); var crossover = new UniformCrossover(0.5f); var mutation = new UniformMutation(true); var population = new Population(SettingsLoader.Data.MinPopulation, SettingsLoader.Data.MaxPopulation, chromosome); var geneticAlgorithm = new GeneticAlgorithm(population, fitness, selection, crossover, mutation); geneticAlgorithm.Termination = new GenerationNumberTermination(SettingsLoader.Data.GenerationsCount); geneticAlgorithm.GenerationRan += GeneticAlgorithm_GenerationRan; _generationStopwatch = new Stopwatch(); _generationStopwatch.Start(); geneticAlgorithm.Start(); Console.WriteLine("Best solution found has {0} fitness.", geneticAlgorithm.BestChromosome.Fitness); Console.ReadLine(); }
static void Main(string[] args) { SettingsLoader.Init("settings.json"); new TournamentArbiter().Run(); }