예제 #1
0
 public override AbstractTrack Clone()
 {
     ClosedTrack track = new ClosedTrack(this.Genotype, _graph);
     track.FirstParent = this.FirstParent;
     track.SecondParent = this.SecondParent;
     return (AbstractTrack)track;
 }
예제 #2
0
 public void ClosedTrackConstructorTest()
 {
     AbstractTrack track = new ClosedTrack(CountOfAllele, _graph, true);
     Assert.IsTrue(track.Genotype.Length == CountOfAllele);
     Assert.IsFalse(Array.Exists(track.Genotype, NegativeNumber));
     Assert.IsFalse(Array.Exists(track.Genotype, UpperLimitNumber));
     Assert.IsTrue(track.TypeOfCrossingover == AbstractCrossingover.WithoutCrossingover);
     Assert.IsTrue(track.TypeOfMutation == AbstractMutation.WithoutMutation);
     Assert.IsTrue(track.TypeOfSelection == AbstractSelection.WithoutSelection);
 }
 public void MyTestInitialize()
 {
     int[,] ribs = new int[15, 2] { { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 0, 5 }, { 1, 2 }, { 1, 3 }, { 1, 4 }, { 1, 5 }, { 2, 3 }, { 2, 4 }, { 2, 5 }, { 3, 4 }, { 3, 5 }, { 4, 5 } };
     double[] weights = new double[] { 1, 2, 3, 4, 1, 1, 3, 3, 3, 1, 2, 5, 1, 5, 1 };
     _graph = new UndirectedConnectedGraph(ribs, weights);
     _closedTracks = new AbstractTrack[4];
     int[] trackPoints1 = new int[] { 0, 2, 1, 3, 5, 4 };
     int[] trackPoints2 = new int[] { 1, 3, 0, 2, 4, 5 };
     int[] trackPoints3 = new int[] { 2, 1, 0, 3, 5, 4 };
     int[] trackPoints4 = new int[] { 2, 3, 0, 1, 4, 5 };
     _closedTracks[0] = new ClosedTrack(trackPoints1, _graph);
     _closedTracks[1] = new ClosedTrack(trackPoints2, _graph);
     _closedTracks[2] = new ClosedTrack(trackPoints3, _graph);
     _closedTracks[3] = new ClosedTrack(trackPoints4, _graph);
 }
예제 #4
0
        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);
            }
        }
예제 #5
0
 public override AbstractTrack EmptyClone()
 {
     ClosedTrack track = new ClosedTrack(this.Genotype.Length, _graph, false);
     return (AbstractTrack)track;
 }
예제 #6
0
 public void MyTestInitialize()
 {
     int[,] ribs = new int[6, 2] { { 0, 1 }, { 0, 2 }, { 0, 3 }, { 1, 2 }, { 1, 3 }, { 2, 3 } };
     double[] weights = new double[] { 3, 5.5, 10, 7, 8, 9 };
     _graph = new UndirectedConnectedGraph(ribs, weights);
     _track = new ClosedTrack(_trackPoints, _graph);
 }