code: def _get_masses(fitnesses):
      
      # Obtain constants
      best_fitness = max(fitnesses)
      worst_fitness = min(fitnesses)
      fitness_range = best_fitness - worst_fitness
  
      # Calculate raw masses for each solution
      raw_masses = []
      for fitness in fitnesses:
          # Epsilon is added to prevent divide by zero errors
          raw_masses.append((fitness - worst_fitness) / (fitness_range + EPSILON)
                            + EPSILON)
  
      # Normalize to obtain final mass for each solution
      total_mass = sum(raw_masses)
      masses = []
      for mass in raw_masses:
          masses.append(mass / total_mass)
  
      return masses
docs: Convert fitnesses into masses, as given by GSA algorithm.