@Override
  public void evaluate(DoubleSolution solution) {
    double[] x = new double[getNumberOfVariables()];
    for (int i = 0; i < solution.getNumberOfVariables(); i++) {
      x[i] = solution.getVariableValue(i) ;
    }

  	int count1, count2;
		double sum1, sum2, yj, hj ;
		sum1   = sum2   = 0.0;
		count1 = count2 = 0;
    
    for (int j = 2 ; j <= getNumberOfVariables(); j++) {
			yj = x[j-1]-Math.sin(6.0*Math.PI*x[0]+j*Math.PI/getNumberOfVariables());
			hj = 2.0*yj*yj - Math.cos(4.0*Math.PI*yj) + 1.0;
			if (j % 2 == 0) {
				sum2  += hj;
				count2++;
			} else {
				sum1  += hj;
				count1++;
			}
    }
    hj = (0.5/n + epsilon)*Math.abs(Math.sin(2.0*n*Math.PI*x[0]));

    solution.setObjective(0, x[0] + hj + 2.0*sum1 / (double)count1);
    solution.setObjective(1, 1.0 - x[0] + hj + 2.0*sum2 / (double)count2);
  }
@ Override public void evaluate ( DoubleSolution solution ) { double [ ] x = new double [ getNumberOfVariables ( ) ] ; for ( int i = 0 ; i < solution . getNumberOfVariables ( ) ; i ++ ) { x [ i ] = solution . getVariableValue ( i ) ; } int count1 , count2 ; double sum1 , sum2 , yj , hj ; sum1 = sum2 = 0.0 ; count1 = count2 = 0 ; for ( int j = 2 ; j <= getNumberOfVariables ( ) ; j ++ ) { yj = x [ j - 1 ] - Math . sin ( 6.0 * Math . PI * x [ 0 ] + j * Math . PI / getNumberOfVariables ( ) ) ; hj = 2.0 * yj * yj - Math . cos ( 4.0 * Math . PI * yj ) + 1.0 ; if ( j % 2 == 0 ) { sum2 += hj ; count2 ++ ; } else { sum1 += hj ; count1 ++ ; } } hj = ( 0.5 / n + epsilon ) * Math . abs ( Math . sin ( 2.0 * n * Math . PI * x [ 0 ] ) ) ; solution . setObjective ( 0 , x [ 0 ] + hj + 2.0 * sum1 / ( double ) count1 ) ; solution . setObjective ( 1 , 1.0 - x [ 0 ] + hj + 2.0 * sum2 / ( double ) count2 ) ; }
Evaluate() method