net.sourceforge.cilib.functions.continuous.unconstrained.ModifiedSchaffer2 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cilib-library Show documentation
Show all versions of cilib-library Show documentation
A library of composable components enabling simpler Computational Intelligence
The newest version!
/** __ __
* _____ _/ /_/ /_ 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;
/**
* Modified Schaffer Function 2.
*
*
* Characteristics:
*
* - Multi-modal
* - Non-Seperable
* - Regular
*
*
*
*
* Reference:
* @article{
* mishra-some,
* title={{Some new test functions for global optimization and performance of repulsive particle swarm method}},
* author={Mishra, S.K. and Campus, N.}
* }
*
*
*/
public class ModifiedSchaffer2 extends ContinuousFunction {
/**
* {@inheritDoc}
*/
@Override
public Double f(Vector input) {
double sum = 0.0;
double square1, square2, numerator, denominator;
for (int j = 0; j < input.size() - 1; j++) {
square1 = input.doubleValueOf(j) * input.doubleValueOf(j);
square2 = input.doubleValueOf(j + 1) * input.doubleValueOf(j + 1);
numerator = Math.pow(Math.sin(square1 - square2), 2) - 0.5;
denominator = Math.pow((1 + 0.001 * (square1 + square2)), 2);
sum += 0.5 + (numerator / denominator);
}
return new Double(sum);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy