資源簡介
用于函數優化的五個測試函數,De Jong精選了5個測試函數,這些函數差異表現在連續性、單峰與多峰、二次與非二次、低維與高維、確定函數與隨機函數。可以比較完整的測試算法性能。

代碼片段和文件信息
/************************************************************
;???????????????????????????????????????????????????????????*
;??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?(01)?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.00.016.032.0}
??{-32.0-16.00.016.032.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?i
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????12841??2010-02-03?11:44??img51.gif
?????文件???????3177??2010-01-17?21:08??dejong.c
-----------?---------??----------?-----??----
????????????????16018????????????????????2
- 上一篇:Unity合并網格Demo
- 下一篇:模糊測試
評論
共有 條評論