private void testAndCorrectNumerics(
      CMAEvolutionaryAlgorithm algorithm, int N, List<Individual> individuals) {

    /*
     * Flat fitness, Test if funtion values are identical
     */
    /*
     * we should sort the individuals by fitness value
     */
    Collections.sort(individuals, algorithm.getComparator());

    if (algorithm.getGenerations() > 0) {
      if (individuals.get(0).getFitness()
          == individuals
              .get((int) Math.min(algorithm.getLambda() - 1, algorithm.getLambda() / 2.0 + 1) - 1)
              .getFitness()) {
        if (debug) {
          System.err.println(
              "WARNING - Flat fitness landscape, consider reformulation of fitness,"
                  + "step-size increased");
        }

        algorithm.setSigma(
            algorithm.getSigma() * Math.exp((0.2 + algorithm.getCs() / algorithm.getDamps())));
      }
    }

    /*
     * Align (renormalize) scale C and (consequently sigma)
     */
    /*
     * e.g. for infinite stationary state simulations (noise handling needs to be introduces for
     * that)
     */
    /*
     * handling needs to be introduced for that)
     */
    double fac = 1;
    if (StatUtils.max(algorithm.getDiag()) < 1.0e-6) {
      fac = 1.0 / StatUtils.max(algorithm.getDiag());
    } else if (StatUtils.min(algorithm.getDiag()) > 1.0e+4) {
      fac = 1.0 / StatUtils.min(algorithm.getDiag());
    }

    if (fac != 1.0) {
      algorithm.setSigma(algorithm.getSigma() / fac);
      for (int i = 0; i < N; i++) {
        algorithm.getPc()[i] *= fac;
        algorithm.getDiag()[i] *= fac;
        for (int j = 0; j <= i; j++) {
          algorithm.getC()[i][j] *= fac * fac;
        }
      }
    }
  }