BBOBenchmarks extends Problem implements SimpleProblemForm { void schwefel(double fAdd, int genomeSize, double[] genome, double tmp, double[] tmx, double[] tmpvect, double fPen, double value, double fit, Individual ind, EvolutionState state, int threadnum) { int i, j; double condition = 10.0; fPen = 0.0; fAdd = fOpt; for (i = 0; i < genomeSize; i++) { tmpvect[i] = 2. * genome[i]; if (xOpt[i] < 0.) tmpvect[i] *= -1.; } tmx[0] = tmpvect[0]; for (i = 1; i < genomeSize; i++) { tmx[i] = tmpvect[i] + 0.25 * (tmpvect[i - 1] - 2. * Math.abs(xOpt[i - 1])); } for (i = 0; i < genomeSize; i++) { tmx[i] -= 2 * Math.abs(xOpt[i]); tmx[i] *= Math.pow(Math.sqrt(condition), ((double) i) / ((double) (genomeSize - 1))); tmx[i] = 100. * (tmx[i] + 2 * Math.abs(xOpt[i])); } for (i = 0; i < genomeSize; i++) { tmp = Math.abs(tmx[i]) - 500.0; if (tmp > 0.) { fPen += tmp * tmp; } } fAdd += 0.01 * fPen; for (i = 0; i < genomeSize; i++) { value += tmx[i] * Math.sin(Math.sqrt(Math.abs(tmx[i]))); } value = 0.01 * ((418.9828872724339) - value / (double) genomeSize); value += fAdd; fit = (-value); ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0); }  static void main(String[] args); void setup(final EvolutionState state, final Parameter base); void evaluate(EvolutionState state, Individual ind, int subpopulation, int threadnum); static final String P_GENOME_SIZE; static final String P_WHICH_PROBLEM; static final String P_NOISE; static final String P_REEVALUATE_NOISY_PROBLEMS; static final String P_ZERO_IS_BEST; static final String P_XOPT; final public String[] problemTypes; final static public int SPHERE; final static public int ELLIPSOIDAL; final static public int RASTRIGIN; final static public int BUCHE_RASTRIGIN; final static public int LINEAR_SLOPE; final static public int ATTRACTIVE_SECTOR; final static public int STEP_ELLIPSOIDAL; final static public int ROSENBROCK; final static public int ROSENBROCK_ROTATED; final static public int ELLIPSOIDAL_2; final static public int DISCUS; final static public int BENT_CIGAR; final static public int SHARP_RIDGE; final static public int DIFFERENT_POWERS; final static public int RASTRIGIN_2; final static public int WEIERSTRASS; final static public int SCHAFFERS_F7; final static public int SCHAFFERS_F7_2; final static public int GRIEWANK_ROSENBROCK; final static public int SCHWEFEL; final static public int GALLAGHER_GAUSSIAN_101ME; final static public int GALLAGHER_GAUSSIAN_21HI; final static public int KATSUURA; final static public int LUNACEK; final public String[] noiseTypes; final static public int NONE; final static public int GAUSSIAN; final static public int UNIFORM; final static public int CAUCHY; final static public int GAUSSIAN_MODERATE; final static public int UNIFORM_MODERATE; final static public int CAUCHY_MODERATE; public int problemType; public int noise; public boolean reevaluateNoisyProblems; public boolean zeroIsBest; static final int NHIGHPEAKS21; static final int NHIGHPEAKS22; final static public double TOL; }
@Test public void testSchwefel() { for (int i = 0; i < 1000; i++) { BBOBenchmarks instance = new BBOBenchmarks(); params.set(BASE.push(BBOBenchmarks.P_WHICH_PROBLEM), "schwefel"); instance.setup(state, BASE); final DoubleVectorIndividual ind = new DoubleVectorIndividual(); ind.setGenome(new double[] { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.0 }); ind.fitness = new SimpleFitness(); instance.evaluate(state, ind, 0, 0); assertTrue(instance.problemType == 19); assertTrue(ind.fitness.fitness() <= -instance.fOpt); } }