net.sourceforge.cilib.functions.continuous.unconstrained.EggHolder 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;
import com.google.common.base.Preconditions;
/**
* The Egg Holder.
*
* Reference: S.K. Mishra, Some New Test Functions
* for Global Optimization and Performance of Repulsive Particle
* Swarm Methods, Technical Report, North-Eastern Hill University,
* India, 2006
*
* Note: n >= 2
*
* Minimum:
*
* - f(x*) approx -959.64
* - x* = (512,404.2319) for n=2
* - for x_i in [-512,512]
*
*
*
* Characteristics:
*
* - Only defined for 2+ dimensions
* - Multimodal
* - Non-separable
* - Not regular
*
*
*
* R(-512.0,512.0)^30
*
*/
public class EggHolder extends ContinuousFunction {
private static final long serialVersionUID = 358993985066821115L;
@Override
public Double f(Vector input) {
Preconditions.checkArgument(input.size() >= 2, "EggHolder function is only defined for 2 or more dimensions");
double sum = 0.0;
for (int i = 0; i < input.size() - 1; i++) {
sum += (-1*(input.doubleValueOf(i+1) + 47)
*Math.sin(Math.sqrt(Math.abs(input.doubleValueOf(i+1) + input.doubleValueOf(i)/2 + 47)))
+ Math.sin(Math.sqrt(Math.abs(input.doubleValueOf(i) - (input.doubleValueOf(i+1)+47))))
*(-1*input.doubleValueOf(i)));
}
return sum;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy