code: @Override
    public void evaluate(DoubleSolution solution) {
      int numberOfVariables = solution.getNumberOfVariables();
      int numberOfObjectives = solution.getNumberOfObjectives();
  
      double[] x = new double[numberOfVariables];
      double[] f = new double[numberOfObjectives];
  
      for (int i = 0; i < numberOfVariables; i++) {
        x[i] = solution.getVariableValue(i);
      }
  
      // evaluate g,h
      double g = 0, h = 0, sub1;
      for (int i = numberOfObjectives - 1; i < numberOfVariables; i++) {
        g += x[i];
      }
      g = 1 + 9 * g / (numberOfVariables - numberOfObjectives + 1);
      sub1 = 1 + g;
      for (int i = 0; i < numberOfObjectives - 1; i++) {
        h += (x[i] * (1 + Math.sin(3 * Math.PI * x[i])) / sub1);
      }
      h = numberOfObjectives - h;
      // evaluate f1,...,m-1,m
      for (int i = 0; i < numberOfObjectives; i++) {
        f[i] = x[i];
      }
      f[numberOfObjectives - 1] = h * sub1;
  
      for (int i = 0; i < numberOfObjectives; i++) {
        solution.setObjective(i, f[i]);
      }
  
    }
docs: Evaluates a solution
  
  @param solution The solution to evaluate