public void MutationTest() { NotRandomMutation target = new NotRandomMutation(); target.Mutation(_mutant); Assert.IsFalse(TwoIntArrayEquals(_mutant.Genotype, _subject.Genotype)); Assert.IsTrue(IsItemsUnique(_mutant.Genotype)); Assert.IsTrue(_mutant.TypeOfMutation == NotRandomMutation.MutationName); }
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); } }