code: def _diversity_metric(solution, population):
      
      # Edge case for empty population
      # If there are no other solutions, the given solution has maximum diversity
      if population == []:
          return 1.0
  
      return (
          sum([_manhattan_distance(solution, other) for other in population])
          # Normalize (assuming each value in solution is in range [0.0, 1.0])
          # NOTE: len(solution) is maximum manhattan distance
          / (len(population) * len(solution)))
docs: Return diversity value for solution compared to given population.
  
      Metric is sum of distance between solution and each solution in population,
      normalized to [0.0, 1.0].