net.sourceforge.cilib.functions.continuous.unconstrained.Michalewicz 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;
/**
* Michalewicz funtion 12.
*
** Reference:
* http://www.geatbx.com/docu/fcnindex-01.html#TopOfPage
*
* Minimum:
*
* - if n=5 then f(x*) = -4.687
* - if n=10 then f(x*) = -9.66
* - for xi in [0, pi]
*
*
*
* Characteristics:
*
* - Multi-modal
* - Has n! local minima
* - Non-separable
*
*
* R(0, 3.141592653589793)^10
*
*/
public class Michalewicz extends ContinuousFunction {
private static final long serialVersionUID = -4391269929189674709L;
/**
* m controls the steepness of the valleys; the larger m, the
* more difficult the search
*/
private int m = 10;
/**
* {@inheritDoc}
*/
@Override
public Double f(Vector input) {
double sumsq = 0.0;
for (int i = 0; i < input.size(); i++) {
double x = input.doubleValueOf(i);
sumsq += Math.sin(x) * Math.pow(Math.sin(((i+1) * x * x)/Math.PI), 2*m);
}
return -sumsq;
}
/**
* Get the current value of M
.
* @return The value of M
.
*/
public int getM() {
return m;
}
/**
* Set the value of M
.
* @param m The value to set.
*/
public void setM(int m) {
this.m = m;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy