code: @Override
    public void evaluate(DoubleSolution solution) {
      int numberOfVariables = getNumberOfVariables() ;
  
      double[] x = new double[numberOfVariables] ;
  
      for (int i = 0; i < numberOfVariables; i++) {
        x[i] = solution.getVariableValue(i) ;
      }
  
      double sum = 0.0;
      double mult = 1.0;
      double d = 4000.0;
      for (int var = 0; var < numberOfVariables; var++) {
        sum += x[var] * x[var];
        mult *= Math.cos(x[var] / Math.sqrt(var + 1));
      }
  
      solution.setObjective(0, 1.0 / d * sum - mult + 1.0);
    }
docs: Evaluate() method