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

📄 griewank.java

📁 基于差分进化与粒子群混合算法优化源程序,这是一个java语言编制的源程序,很实用.
💻 JAVA
字号:
/**
 * Description: Griewank function
 * X*(Optimal point):
 * X1=0
 * X2=-1
 * Y*(Optimal value)
 * Y1=3
 *
 * @ 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] Shi Y H, Eberhart R C. Empirical study of particle swarm optimization.
 * Proc. Congress on Evolutionary Computation, 1999: 1945-1950
 */

package problem.unconstrained;

import problem.*;

public class Griewank extends UnconstrainedProblemEncoder {
  private static int NX = 30; //number of variables
  public Griewank() throws Exception {
    super(NX);
    for(int i=0; i<NX; i++) {
      setDefaultXAt(i, -600, 600); //the range of each variable
    }
  }

  //calculates the objective value
  public double calcTarget(double[] VX) {
    double value1 = 0;
    double value2 = 1;
    for (int i=0; i<NX; i++) {
      value1 += Math.pow(VX[i],2)/4000.0;
      value2 *= Math.cos(VX[i]/Math.sqrt(i+1));
    }
    return value1-value2+1;
  }
}

⌨️ 快捷键说明

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