net.sourceforge.cilib.functions.continuous.unconstrained.Schaffer6 Maven / Gradle / Ivy
/** __ __
* _____ _/ /_/ /_ Computational Intelligence Library (CIlib)
* / ___/ / / / __ \ (c) CIRG @ UP
* / /__/ / / / /_/ / http://cilib.net
* \___/_/_/_/_.___/
*/
package net.sourceforge.cilib.functions.continuous.unconstrained;
import net.sourceforge.cilib.functions.ContinuousFunction;
import net.sourceforge.cilib.type.types.container.Vector;
/**
* Schaffer's F6 generalised, also referred to as the Pathological Function.
*
* Reference: S. Rahnamayan, H. R. Tizhoosh, M. M. A. Salama A novel population initialisation method for accelerating evolutionary algorithms,
* Computers and Mathematics with Applications, 2007
*
* Minimum:
*
* - ƒ(x*) = 0
* - x* = (0, 0, ...., 0)
* - for xi in [-100, 100]
*
*
*
* Characteristics:
*
*
*
*
* R(-100.0,100.0)^30
*/
public class Schaffer6 extends ContinuousFunction {
private static final long serialVersionUID = 4959662717057274057L;
/**
* Evaluate the function and return the evaluation.
*
* @param input The input vector to the function
* @return A double value representing the function evaluation
*/
@Override
public Double f(Vector input) {
double sum = 0;
for (int i = 0; i < input.size()-1; i++) {
double xi = input.doubleValueOf(i);
double xj = input.doubleValueOf(i + 1);
double sinSquared = Math.sin(Math.sqrt((100 * (xi*xi)) + (xj*xj)));
sinSquared *= sinSquared;
double squaredVal = (xi * xi) - (2 * xi * xj) + (xj * xj);
squaredVal *= squaredVal;
sum += 0.5 + ((sinSquared - 0.5) / (1 + (0.001 * squaredVal)));
}
return sum;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy