net.sourceforge.cilib.functions.continuous.unconstrained.Ackley 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;
/**
* The Generalized Ackley.
*
* Reference: T.Back, Evolutionary Algorithms in Theory and Practice,
* Oxford University Press, 1996
*
* Minimum:
*
* - ƒ(x*) = 0
* - x* = (0, 0, ...., 0)
* - for xi in [-32.768,32.768]
*
*
*
* Characteristics:
*
* - Multimodal
* - Seperable
* - Regular
*
*
* R(-32.768, 32.768)^30
*
*
*/
public class Ackley extends ContinuousFunction {
private static final long serialVersionUID = -7803711986955989075L;
/* (non-Javadoc)
* @see net.sourceforge.cilib.functions.redux.ContinuousFunction#evaluate(net.sourceforge.cilib.type.types.container.Vector)
*/
@Override
public Double f(Vector input) {
final int size = input.size();
double sumsq = 0.0;
double sumcos = 0.0;
for (int i = 0; i < size; ++i) {
sumsq += input.doubleValueOf(i) * input.doubleValueOf(i);
sumcos += Math.cos(2 * Math.PI * input.doubleValueOf(i));
}
return -20.0 * Math.exp(-0.2 * Math.sqrt(sumsq / size)) - Math.exp(sumcos / size) + 20 + Math.E;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy