def _calculate_population_energies(self):
        """
        Calculate the energies of all the population members at the same time.
        Puts the best member in first place. Useful if the population has just
        been initialised.
        """
        for index, candidate in enumerate(self.population):
            if self._nfev > self.maxfun:
                break

            parameters = self._scale_parameters(candidate)
            self.population_energies[index] = self.func(parameters,
                                                        *self.args)
            self._nfev += 1

        minval = np.argmin(self.population_energies)

        # put the lowest energy into the best solution position.
        lowest_energy = self.population_energies[minval]
        self.population_energies[minval] = self.population_energies[0]
        self.population_energies[0] = lowest_energy

        self.population[[0, minval], :] = self.population[[minval, 0], :]
dataset/ETHPy150Open scipy/scipy/scipy/optimize/_differentialevolution.py/DifferentialEvolutionSolver._calculate_population_energies/original