public void FindsSimpleSolution() { var random = new SystemRandom(42); var factory = new SimpleGenomeFactory(random); var selection = new BinaryTournamentSelection(random); Environment environment = new SimpleEnvironment(); Ranking ranking = new CrowdingDistanceRanking(1); var evolution = new Evolution(100, 0.4, 0.4, factory, selection); var genomes = evolution.Initialize(); double score = 0; for (int i = 0; i < 100; i++) { // evaluate var population = genomes.Select(environment.Evaluate).ToList(); // rank ranking.Rank(population); // keep score var best = population[0]; Console.WriteLine(best); score = best.GetScore(0); // evolve genomes = evolution.Evolve(population, random); } Assert.Greater(score, 30); }
public void A_settlement_with_three_neighbours_will_live_through_evolution() { var expected = new Settlement(1, 1); var evolution = Evolution.Evolve(new List <Settlement> { new Settlement(0, 1), expected, new Settlement(2, 1), new Settlement(1, 2) }); Assert.Contains(expected, evolution.ToList()); }
static void Main(string[] args) { //var t = new Tournament(); //t.Giostra(); //t.Sort(); //t.ShowResults(); var e = new Evolution(); e.Evolve(); }
public void NewGeneration() { var best = Evolution.Evolve() as CarGenotype; if (best.CheckpointsPassed > lastBestFitness) { lastBestFitness = best.CheckpointsPassed; var str = ""; for (int i = 0; i < best.Parameters.Length; i++) { str += best.Parameters[i].ToString("0.###################################") + ";"; } File.WriteAllText("C:/temp/ki.txt", str); } UpdateCarEntities(); }