def testRank(self):
     fitness = MockFitness()
     chromosomes = [[21], [2], [3], [19], [6]]
     topChromosomes = es.rank(chromosomes, 2, fitness)
     self.assertEqual(topChromosomes, [[21], [19]])
1. Randomly generate parents for generation 0 using uniform distribution for x1, x2 variables. Sigma = 1.0
2. Save the current best parent in generation 0
3. Do recombination on parents to create offspring
    - Use discrete global recombination on variables
    - Use intermediate global recombination on steps/sigmas
4. Mutate offspring
5. Use death penalty approach to weed out offspring that do not meet constraints
6. Create more offspring using steps 3, 4, and 5 until desired number of offspring reached
7. Do survivor selection using (mu, lambda) approach
8. Compare best of current generation with best overall. If current is better, make it the best overall
9. Repeat until maxGenerations reached
"""
random.seed(seed)

parents = es.createGeneration0(numParents, fitness, initialSigma, random.uniform)
parents = es.rank(parents, len(parents), fitness)
currentBest = parents[0]

for i in xrange(maxGenerations):
    validOffspring = []
    offspringNeeded = numOffspring
    while offspringNeeded > 0:
        offspring = es.recombination(parents, offspringNeeded, vRecombination, sRecombination, random.sample)      
        mutatedOffspring = es.mutation(offspring, random.gauss)
        validOffspring.extend(es.deathPenalty(mutatedOffspring, fitness))
        offspringNeeded = numOffspring - len(validOffspring)
    parents = survivorSelection(parents, validOffspring, fitness)
    currentBest = es.compareBestFitness(currentBest, parents[0], fitness)

    if log['sample'] is not None  and i % log['sample'] == 0:
        print "Generation {}:".format(i),