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

📄 derandom.java

📁 Differential Evolution(JAVA)
💻 JAVA
字号:
package DeApp1.de;
import java.io.*;
import java.util.Random;   // Provides random number generators


public class DERandom extends Random
/***********************************************************
**                                                        **
** Random number generator. Certainly not the best one    **
** around. So if you are not satisfied, implement your    **
** own one.                                               **
**                                                        **
** Authors:            Mikal Keenan                       **
**                     Rainer Storn                       **
**                                                        **
***********************************************************/
{

  public DERandom ()
  /*********************************************************
  ** Constructor initializes the generator.               **
  *********************************************************/
  { 
	  setMySeed (0);
  }


  public void setMySeed (long seed)
  /*********************************************************
  ** Random initialization. Hence your optimization       **
  ** results may differ from run to run.                  **
  *********************************************************/
  { 
	if (seed == 0)
    seed = (long) System.currentTimeMillis();
    setSeed (seed);
  }


  public final int nextValue (int max) // BUG:: infinite loop if this method is called next
  /*********************************************************
  ** Fetch the next integer random number ex [0,max].     **
  *********************************************************/
  {
    return (int) (nextDouble() * (double) max);
  }


  public final double nextValue (double range) //BUG:: infinite loop if this method is called next
  /************************************************************
  ** Fetch the next double random number ex [-range,+range]. **
  ************************************************************/
  {
    return range * (1.0 - 2.0 * nextDouble());
  }
}





⌨️ 快捷键说明

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