public void SelectionTest() { TournamentSelection target = new TournamentSelection(); target.Selection(_parents, _childs); Assert.IsTrue(TwoIntArrayEquals(_parents[0].Genotype, _expected[0].Genotype)); Assert.IsTrue(TwoIntArrayEquals(_parents[1].Genotype, _expected[1].Genotype)); Assert.IsTrue(TwoIntArrayEquals(_parents[2].Genotype, _expected[2].Genotype)); Assert.IsTrue(_parents[0].TypeOfSelection == TournamentSelection.SelectionName); }
public Configuration() { AliasCrossingover = new List<string>(); AliasMutations = new List<string>(); AliasSelection = new List<string>(); ConfigName = "Новая конфигурация"; AlgMode = AlgorithmMode.Singl; CountOfReplays = 1; ProbOfCrossingover = 100; ProbOfMutation = 100; FitnessParam = 10; Mutation = new NotRandomMutation(); AliasMutations.Add(Mutation.GetName()); Crossingover = new CyclicalCrossingover(); AliasCrossingover.Add(Crossingover.GetName()); Selection = new TournamentSelection(); AliasSelection.Add(Selection.GetName()); Graph = new UndirectedConnectedGraph(10); FitnessFunction = new BestReps((int)FitnessParam); Tracks = new AbstractTrack[10]; Random r = new Random(); for (int i = 0; i < Tracks.Length; i++) { int[] points = new int[10]; for (int j = 0; j < points.Length; j++) { points[j] = -1; } int newRandomChromosome = r.Next(points.Length - 1); for (int j = 0; j < points.Length; j++) { while (points.Contains(newRandomChromosome)) { newRandomChromosome = r.Next(points.Length); } points[j] = newRandomChromosome; } Tracks[i] = new ClosedTrack(points, Graph); } }