⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 michalewicz_g5.java

📁 用JAVA语言编写
💻 JAVA
字号:
/**
 * Description: Benchmark function (Michalewicz's G5).
 * @The equality constraints are replaced by |g(x)|<1E-4
 * X*(Optimal point):
 * X1=679.9453657862382
 * X2=1026.0670835276146
 * X3=0.11887633173654996
 * X4=-0.3962335687510607
 * Y*(Optimal value)
 * Y1=5126.498109595283
 *
 * @ Author        Create/Modi     Note
 * Xiaofeng Xie    Dec 28, 2001
 * Xiaofeng Xie    Mar 02, 2003
 * Xiaofeng Xie    May 18, 2004
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * Please acknowledge the author(s) if you use this code in any way.
 *
 * @version 1.0
 * @Since MAOS1.0
 *
 * @References:
 * [1] Hock W, Schittkowski K. Test Examples for Nonlinear Programming
 * Codes. Springer-Verlag, 1981, Lecture Notes in Econ. and Math. Syst.
 * [2] 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_G5 extends ProblemEncoder {
  static final int NX = 4;
  static final int NY = 6;
  public Michalewicz_G5() throws Exception {
    super(NX, NY);
    for(int i=0; i<2; i++) {
      setDefaultXAt(i, 0, 1200);
    }
    for(int i=2; i<NX; i++) {
      setDefaultXAt(i, -0.55, 0.55);
    }

    setDefaultYAt(0, BasicBound.MINDOUBLE, BasicBound.MINDOUBLE);
    setDefaultYAt(1, 0, BasicBound.MAXDOUBLE);
    setDefaultYAt(2, 0, BasicBound.MAXDOUBLE);
    setDefaultYAt(3, 0, 1E-4);  //<1E-4
    setDefaultYAt(4, 0, 1E-4);  //<1E-4
    setDefaultYAt(5, 0, 1E-4);  //<1E-4
  }

  protected double calcTargetAt(int index, double[] VX) {
    double value = 0;
    switch(index) {
      case 0:
        value = 3*VX[0]+0.000001*VX[0]*VX[0]*VX[0]+2*VX[1]+(0.000002/3.0)*VX[1]*VX[1]*VX[1];
        break;
      case 1:
        value = VX[3]-VX[2]+0.55;
        break;
      case 2:
        value = VX[2]-VX[3]+0.55;
        break;
      case 3:
        value = 1000*Math.sin(-1*VX[2]-0.25)+1000*Math.sin(-1*VX[3]-0.25)+894.8-VX[0];
        value = Math.abs(value);
        break;
      case 4:
        value = 1000*Math.sin(VX[2]-0.25)+1000*Math.sin(VX[2]-1*VX[3]-0.25)+894.8-VX[1];
        value = Math.abs(value);
        break;
      case 5:
        value = value = 1000*Math.sin(VX[3]-0.25)+1000*Math.sin(VX[3]-VX[2]-0.25)+1294.8;
        value = Math.abs(value);
        break;
    default:
      return Double.NaN;
    }
    return value;
  }
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -