📄 michalewicz_g3.java
字号:
/**
* Description: Benchmark function (Michalewicz's G3).
* X*(Optimal point):
* X1~X10: 1/sqrt(n)=0.31622776601683794 (as n=10)
* Y*(Optimal value)
* Y1=1
*
* @ Author Create/Modi Note
* Xiaofeng Xie Dec 28, 2001
* Xiaofeng Xie Mar 02, 2003
* Xiaofeng Xie May 11, 2004
*
* @version 1.0
* @Since MAOS1.0
*
* @References:
* [1] Koziel S, Michalewicz Z. Evolutionary algorithms, homomorphous
* mappings, and constrained parameter optimization. Evolutionary
* Computation, 1999, 7: 19-44
*/
package problem.constrained;
import problem.*;
import Global.*;
public class Michalewicz_G3 extends ProblemEncoder {
static final int NX = 10;
static final int NY = 2;
public Michalewicz_G3() throws Exception {
super(NX, NY);
for(int i=0; i<NX; i++) {
setDefaultXAt(i, 0, 1);
}
setDefaultYAt(0, BasicBound.MAXDOUBLE, BasicBound.MAXDOUBLE);
setDefaultYAt(1, 0, 1E-4);
}
protected double calcTargetAt(int index, double[] VX) {
double value = 0;
switch(index) {
case 0:
value = Math.pow(Math.sqrt(NX),NX);
for (int j=0; j<NX; j++) {
value *= VX[j];
}
break;
case 1:
value = -1;
for (int j=0; j<NX; j++) {
value += Math.pow(VX[j],2);
}
value = Math.abs(value);
break;
default:
return Double.NaN;
}
return value;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -