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

📄 michalewicz_g2.java

📁 关于改进pso的源程序
💻 JAVA
字号:
/**
 * Description: Benchmark function (Michalewicz's G2).
 * X*(Optimal point):
 * X1=3.16215255  X2=3.12817483  X3=3.09502235  X4=3.06133802  X5=3.02826842
 * X6=2.9939775   X7=2.95839222  X8=2.92204548  X9=0.49527256  X10=0.48869229
 * X11=0.48196674 X12=0.47690625 X13=0.4714034  X14=0.46580564 X15=0.46039198
 * X16=0.45733127 X17=0.4524957  X18=0.44864981 X19=0.44406217 X20=0.44032687
 * Y*(Optimal value)
 * Y1=0.8036188218162693
 *
 * @ Author        Create/Modi     Note
 * Xiaofeng Xie    Dec 28, 2001
 * Xiaofeng Xie    Mar 02, 2003
 * Xiaofeng Xie    May 11, 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] 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_G2 extends ProblemEncoder {
  static final int NX = 20;
  static final int NY = 3;
  public Michalewicz_G2() throws Exception {
    super(NX, NY);
    for(int i=0; i<NX; i++) {
      setDefaultXAt(i, 0, 10);
    }

    setDefaultYAt(0, BasicBound.MAXDOUBLE, BasicBound.MAXDOUBLE); // Maximize Objective
    setDefaultYAt(1, 0, BasicBound.MAXDOUBLE);    //Largethan constraints (>0)
    setDefaultYAt(2, BasicBound.MINDOUBLE, 0);    //Lessthan constraints  (<0)
  }

  protected double calcTargetAt(int index, double[] VX) {
    double value = 0;
    switch(index) {
      case 0:
        double value1 = 0;
        double value2 = 1;
        double value3 = 0;
        for (int j=0; j<NX; j++) {
          value1 += Math.pow(Math.cos(VX[j]),4);
          value2 *= Math.pow(Math.cos(VX[j]),2);
          value3 += (j+1)*Math.pow(VX[j],2);
        }
        value = Math.abs((value1-2*value2)/Math.sqrt(value3));
        break;
      case 1:
        value = 1;
        for (int j=0; j<NX; j++) {
          value *= VX[j];
        }
        value -= 0.75;
        break;
      case 2:
        value = 0;
        for (int j=0; j<NX; j++) {
          value += VX[j];
        }
        value-=7.5*NX;
        break;
    default:
      return Double.NaN;
    }
    return value;
  }
}

⌨️ 快捷键说明

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