public void ItWillRunMultipleGenerations()
        {
            var ga         = new OrderedGeneticAlgorithm(_configuration, _exampleGenes);
            var runDetails = ga.Run();

            Assert.AreEqual(_configuration.MaxGenerations, runDetails.CurrentGeneration);
        }
        public void ItSetsTheStartAndEndTimeOfARun()
        {
            var ga  = new OrderedGeneticAlgorithm(_configuration, _exampleGenes);
            var run = ga.Run();

            Assert.AreEqual(_configuration.MaxGenerations, run.CurrentGeneration);
            Assert.IsTrue(run.GetTotalMSToRun() >= 0);
        }
        public void ItReturnsAnObjectWithDetailsOfTheRun()
        {
            var ga  = new OrderedGeneticAlgorithm(_configuration, _exampleGenes);
            var run = ga.Run();

            Assert.AreEqual(_configuration.MaxGenerations, run.CurrentGeneration);
            Assert.AreNotEqual(-1, run.BestChromosome.FitnessScore);
        }
Пример #4
0
        public override GARun Run(GAConfiguration configuration)
        {
            Configuration = configuration;

            var options = GetOptions();

            GeneticAlgorithm = new OrderedGeneticAlgorithm(Configuration, options);
            return(GeneticAlgorithm.Run());
        }
        public void ItIsRepeatable()
        {
            var ga         = new OrderedGeneticAlgorithm(_configuration, _exampleGenes);
            var runDetails = ga.Run();

            Assert.AreEqual(_configuration.MaxGenerations, runDetails.CurrentGeneration);

            Assert.AreEqual(LastName.Bernard, runDetails.BestChromosome.LastName);
            Assert.AreEqual(80, runDetails.BestChromosome.FitnessScore);
        }
        public void ItKeepsTrackOfTheBestScore()
        {
            var ga         = new OrderedGeneticAlgorithm(_configuration, _exampleGenes);
            var runDetails = ga.Run();

            Assert.AreEqual(_configuration.MaxGenerations, runDetails.CurrentGeneration);

            Assert.AreEqual(LastName.Bernard, runDetails.BestChromosome.LastName);
            Assert.AreEqual(FirstName.Anakin, runDetails.BestChromosome.FirstName);
            Assert.AreEqual(80, runDetails.BestChromosome.FitnessScore);

            var lowest       = runDetails.Population.Chromosomes.Select(o => o.FitnessScore).Min();
            var lastBestSeen = runDetails.Population.Chromosomes.Where(o => o.FitnessScore == lowest).First();

            Assert.AreEqual(LastName.Strickland, lastBestSeen.LastName);
            Assert.AreEqual(FirstName.Aylin, lastBestSeen.FirstName);
        }