net.sourceforge.cilib.functions.continuous.unconstrained.Quadric 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 Quadric Function
*
*
* Minimum:
*
* - ƒ(x*) = 0
* - x* = (0, 0, ...., 0)
* - for xi in [-100,100]
*
*
*
*
* Characteristics:
*
* - Unimodal
* - Continuous
*
*
*
* R(-100, 100)^30
*
*/
public class Quadric extends ContinuousFunction {
private static final long serialVersionUID = -2555670302543357421L;
/**
* {@inheritDoc}
*/
@Override
public Double f(Vector input) {
double sumsq = 0;
for (int i = 0; i < input.size(); ++i) {
double sum = 0;
for (int j = 0; j <= i; ++j) {
sum += input.doubleValueOf(j);
}
sumsq += sum * sum;
}
return sumsq;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy