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

📄 michalewicz_g13.java

📁 关于改进pso的源程序
💻 JAVA
字号:
/**
 * Description: Benchmark function (RY's G13, or Deb's F7).
 *
 * @ Author        Create/Modi     Note
 * Xiaofeng Xie    Apr 19, 2003   xiaofengxie@tsinghua.org.cn
 *
 * 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] Runarsson T P, Yao X. Stochastic ranking for constrained evolutionary
 *  optimization. IEEE Trans. on Evolutionary Computation, 2000, 4(3): 284-294
 * [2] Deb K. An efficient constraint handling method for genetic algorithms.
 * Computer Methods in Applied Mechanics and Engineering, 2000, 186(2-4): 311-338
 */

package problem.constrained;

import problem.*;
import Global.*;

public class Michalewicz_G13 extends ProblemEncoder {
  public Michalewicz_G13() throws Exception {
    super(5, 4);
    for(int i=0; i<5; i++) {
      setDefaultXAt(i, -10, 10);
    }

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

  protected double calcTargetAt(int index, double[] VX) {
    double value = 0;
    switch(index) {
      case 0:
        value = Math.exp(VX[0]*VX[1]*VX[2]*VX[3]*VX[4]);
        break;
      case 1:
        value = 0;
        for(int j=0; j<5; j++) {
          value += VX[j]*VX[j];
        }
        value = value-10;
        break;
      case 2:
        value = VX[1]*VX[2]-5*VX[3]*VX[4];
        break;
      case 3:
        value = Math.pow(VX[0], 3)+Math.pow(VX[1], 3)+1;
        break;
      default:
        return Double.NaN;
    }
    return value;
  }
}

⌨️ 快捷键说明

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