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 ;
      for (int var = 0; var < numberOfVariables; var++) {
        double value = x[var];
        sum += value * value;
      }
  
      solution.setObjective(0, sum);
    }
docs: Evaluate() method