private double obj_func(double[] x_values) {
        int nopt = x_values.length;
        double d = (nopt == 2) ? 200.0 : 4000.0;
        double u1 = 0.0;
        double u2 = 1.0;
        for (int i = 0; i < nopt; i++) {
            u1 += (x_values[i] * x_values[i]) / d;
            u2 *= Math.cos(x_values[i] / Math.sqrt((double) i+1));
        }
        return u1 - u2 + 1;
    }