net.sourceforge.cilib.functions.continuous.unconstrained.Hartman3 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;
/**
* Hartman3.
*
*
* Minimum:
*
* - ƒ(x*) = -3.8756
* - x* = (0.1, 0.55592003, 0.85218259)
* - for xi in [0, 1]
*
*
* R(0,1)^3
*
*/
public class Hartman3 extends ContinuousFunction {
private final double A[][] = {
{3.0, 10.0, 30.0},
{0.1, 10.0, 35.0},
{3.0, 10.0, 30.0},
{0.1, 10.0, 30.5}
};
private final double c[] = {1.0, 1.2, 3.0, 3.2};
private final double p[][] = {
{0.36890, 0.1170, 0.2673},
{0.46990, 0.4387, 0.7470},
{0.10910, 0.8732, 0.5547},
{0.03815, 0.5743, 0.8828}
};
/**
* {@inheritDoc}
*/
@Override
public Double f(Vector input) {
Preconditions.checkArgument(input.size() == 3, "Hartman3 function is only defined for 3 dimensions");
double outerSum = 0.0;
for (int i = 0; i < 4; i++) {
double innerSum = 0.0;
for(int j = 0; j < input.size(); j++) {
innerSum += A[i][j] * Math.pow(input.doubleValueOf(j) - p[i][j], 2);
}
outerSum += c[i] * Math.exp(-innerSum);
}
return -outerSum;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy