@@ -0,0 +1,1892 @@
+import unittest%0Aimport datetime%0Aimport genetic%0A%0A%0Adef test_benchmark(self):%0A    genetic.Benchmark.run(lambda: self.sort_numbers(40))%0A%0Aclass Fitness:%0A    def __init__(self, numbersInSequenceCount, totalGap):%0A        self.NumbersInSequenceCount = numbersInSequenceCount%0A        self.TotalGap = totalGap%0A%0A%0A    # Need to Compare two fitness values:%0A    def __gt__(self, other):%0A        if self.NumbersInSequenceCount != other.NumbersInSequenceCount:%0A            return self.NumbersInSequenceCount %3E other.NumbersInSequenceCount%0A        return self.TotalGap %3C other.TotalGap%0A%0A    def __str__(self):%0A        return %22%7B%7D Sequential, %7B%7D Total Gap, %22.format(self.NumbersInSequenceCount, self.TotalGap)%0A%0Aclass SortedNumbersTests(unittest.TestCase):%0A    def test_sort_10_numbers(self):%0A        self.sort_numbers(10)%0A%0A    def sort_numbers(self, totalNumbers):%0A        geneset = %5Bi for i in range(100)%5D%0A        startTime = datetime.datetime.now()%0A        # For this project...%0A%0A        def fnDisplay(candidate):%0A            display(candidate, startTime)%0A%0A        def fnGetFitness(genes):%0A            return get_fitness(genes)%0A%0A        optimalFitness = Fitness(totalNumbers, 0)%0A        best = genetic.get_best(fnGetFitness, totalNumbers, optimalFitness, geneset, fnDisplay)%0A        self.assertTrue(not optimalFitness %3E best.Fitness)%0A%0A%0Adef get_fitness(genes):%0A    fitness = 1%0A    gap = 0%0A%0A    for i in range(1, len(genes)):%0A        if genes%5Bi%5D %3E genes%5Bi - 1%5D:%0A            fitness += 1%0A        else:%0A            gap += genes%5Bi - 1%5D - genes%5Bi%5D%0A%0A    return Fitness(fitness, gap)%0A%0Adef display(candidate, startTime):%0A    timeDiff = datetime.datetime.now() - startTime%0A    print(%22%7B%7D%5Ct=%3E %7B%7D%5Ct%7B%7D%22.format(', '.join(map(str, candidate.Genes)),%0A                                 candidate.Fitness,%0A                                 timeDiff))%0A%0Aif __name__ == '__main__':%0A    print(%22Running Main Tests%22)%0A    unittest.main()

Create sortedNumbersTests.py