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

📄 the de jong functions f1 - f5.txt

📁 De Jong函数F1-F5的java源码
💻 TXT
字号:
/************************************************************;                                                           *;  William M. Spears					    *;  Navy Center for Applied Research in AI                   *;  Naval Research Laboratory                                *;                                                           *;  Permission is hereby granted to copy all or any part of  *;  this program for free distribution.			    *;                                                           *;************************************************************//* Decode the bit string */int decode(i, j, k)int i, j, k;{   int sum, x, n;   sum = 0;   n = 1;   for (x = k - j; x >= 0; x--) {     if (c[i][x + j] == 1) {       sum = sum + n;     }     n = n * 2;   }   return(sum);}/* 3 variables, 10 bits/variable. */double f1 (i)int i;{	register int x;	double sum, pow();	solution = 78.6;	sum = 0.0;	for (x = 0; x <= 2; x++) {	  sum = sum + pow(((double)(decode(i, (x * 10) + 1, (x * 10) + 10) - 512) / 100.0),			  2.0);	}	return(solution - sum);};/* 2 variables, 12 bits/variable. */double f2 (i)int i;{        double x1, x2;	double pow();	solution = 3905.93;	x1 = (double)(decode(i, 1, 12) - 2048) / 1000.0;	x2 = (double)(decode(i, 13, 24) - 2048) / 1000.0;	return(solution - ((100.0 * pow(pow(x1, 2.0) - x2, 2.0)) + pow(1.0 - x1, 2.0)));};/* 5 variables, 10 bits/variable. */double f3 (i)int i;{	register int x;	int sum;	double temp, pow();	solution = 55.0;	sum = 0;	for (x = 0; x <= 4; x++) {	  temp = (double)(decode(i, (x * 10) + 1, (x * 10) + 10) - 512) / 	         100.0;	  if (temp > 0.0) { sum = sum + (int)temp;}	  else { sum = sum + (int)temp - 1; }	}	return(25.0 - (double)sum);};/* 30 variables, 8 bits/variable. ssrand() needs to be defined to be   a (0,1) gaussian random variable */double f4 (i)int i;{	register int x;	double sum, pow(), ssrand();	double temp, temp2, temp4;	solution = 1248.2;	sum = 0.0;	for (x = 0; x <= 29; x++) {	  temp = ((double)(decode(i, (x * 8) + 1, (x * 8) + 8) - 128) / 100.0);	  temp2 = temp * temp;	  temp4 = temp2 * temp2;	  sum = sum + ((double)i * temp4) + ssrand();	}	return(1248.2 - sum);};/* 2 variables, 17 bits/variable. */static double f5_a[2][5] = {  {-32.0,-16.0,0.0,16.0,32.0},  {-32.0,-16.0,0.0,16.0,32.0}};double f5_j (i, j)int i, j;{	double save, temp, temp2, temp6, pow();	temp = ((double)(decode(i, 1, 17) - 65536) / 1000.0) - f5_a[0][j % 5];	temp2 = temp * temp;	temp6 = temp2 * temp2 * temp2;	save = temp6;	/* The following error was pointed out to me by Andrew Czarn on	   Dec 11, 2000. Apologies for the typo! */      /*temp = ((double)(decode(i, 18, 34) - 65536) / 1000.0) - f5_a[1][j % 5];*/	temp = ((double)(decode(i, 18, 34) - 65536) / 1000.0) - f5_a[1][j / 5];	temp2 = temp * temp;	temp6 = temp2 * temp2 * temp2;	return(save + temp6 + (double)(j + 1));}double f5 (i)int i;{	register int x;	double sum, pow(), f5_j();	solution = 500.0;	sum = 0.0;	for (x = 0; x <= 24; x++) {	  sum = sum + (1.0 / f5_j(i, x));	}	return(500.0 - (1.0 / (sum + .002)));};

⌨️ 快捷键说明

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