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 result = 0.0;
      double a = 10.0;
      double w = 2 * Math.PI;
  
      for (int i = 0; i < numberOfVariables; i++) {
        result += x[i] * x[i] - a * Math.cos(w * x[i]);
      }
      result += a * numberOfVariables;
  
      solution.setObjective(0, result);
    }
docs: Evaluate() method