/*
CEC14 Test Function Suite
Jane Jing Liang (email: liangjing@zzu.edu.cn)
Dec. 20th 2013
1. Run the following command in Matlab window:
mex cec17_func.cpp -DWINDOWS
2. Then you can use the test functions as the following example:
f = cec17_func(x,func_num);
Here x is a D*pop_size matrix.
*/
// #include <WINDOWS.H>
#include <stdio.h>
#include <math.h>
#include <malloc.h>
#include <mex.h>
double *OShift,*M,*y,*z,*x_bound;
int ini_flag=0,n_flag,func_flag,*SS;
// #include <WINDOWS.H>
// #include <stdio.h>
// #include <math.h>
// #include <malloc.h>
#define INF 1.0e99
#define EPS 1.0e-14
#define E 2.7182818284590452353602874713526625
#define PI 3.1415926535897932384626433832795029
void sphere_func (double *, double *, int , double *,double *, int, int); /* Sphere */
void ellips_func(double *, double *, int , double *,double *, int, int); /* Ellipsoidal */
void bent_cigar_func(double *, double *, int , double *,double *, int, int); /* Discus */
void discus_func(double *, double *, int , double *,double *, int, int); /* Bent_Cigar */
void dif_powers_func(double *, double *, int , double *,double *, int, int); /* Different Powers */
void rosenbrock_func (double *, double *, int , double *,double *, int, int); /* Rosenbrock's */
void schaffer_F7_func (double *, double *, int , double *,double *, int, int); /* Schwefel's F7 */
void ackley_func (double *, double *, int , double *,double *, int, int); /* Ackley's */
void rastrigin_func (double *, double *, int , double *,double *, int, int); /* Rastrigin's */
void weierstrass_func (double *, double *, int , double *,double *, int, int); /* Weierstrass's */
void griewank_func (double *, double *, int , double *,double *, int, int); /* Griewank's */
void schwefel_func (double *, double *, int , double *,double *, int, int); /* Schwefel's */
void katsuura_func (double *, double *, int , double *,double *, int, int); /* Katsuura */
void bi_rastrigin_func (double *, double *, int , double *,double *, int, int); /* Lunacek Bi_rastrigin */
void grie_rosen_func (double *, double *, int , double *,double *, int, int); /* Griewank-Rosenbrock */
void escaffer6_func (double *, double *, int , double *,double *, int, int); /* Expanded Scaffer��s F6 */
void step_rastrigin_func (double *, double *, int , double *,double *, int, int); /* Noncontinuous Rastrigin's */
void happycat_func (double *, double *, int , double *,double *, int, int); /* HappyCat */
void hgbat_func (double *, double *, int , double *,double *, int, int); /* HGBat */
/* New functions Noor Changes */
void sum_diff_pow_func(double *, double *, int , double *,double *, int, int); /* Sum of different power */
void zakharov_func(double *, double *, int , double *,double *, int, int); /* ZAKHAROV */
void levy_func(double *, double *, int , double *,double *, int, int); /* Levy */
void dixon_price_func(double *, double *, int , double *,double *, int, int); /* Dixon and Price */
void hf01 (double *, double *, int, double *,double *, int *,int, int); /* Hybrid Function 1 */
void hf02 (double *, double *, int, double *,double *, int *,int, int); /* Hybrid Function 2 */
void hf03 (double *, double *, int, double *,double *, int *,int, int); /* Hybrid Function 3 */
void hf04 (double *, double *, int, double *,double *, int *,int, int); /* Hybrid Function 4 */
void hf05 (double *, double *, int, double *,double *, int *,int, int); /* Hybrid Function 5 */
void hf06 (double *, double *, int, double *,double *, int *,int, int); /* Hybrid Function 6 */
void hf07 (double *, double *, int, double *,double *, int *,int, int); /* Hybrid Function 7 */
void hf08 (double *, double *, int, double *,double *, int *,int, int); /* Hybrid Function 8 */
void hf09 (double *, double *, int, double *,double *, int *,int, int); /* Hybrid Function 9 */
void hf10 (double *, double *, int, double *,double *, int *,int, int); /* Hybrid Function 10 */
void cf01 (double *, double *, int , double *,double *, int); /* Composition Function 1 */
void cf02 (double *, double *, int , double *,double *, int); /* Composition Function 2 */
void cf03 (double *, double *, int , double *,double *, int); /* Composition Function 3 */
void cf04 (double *, double *, int , double *,double *, int); /* Composition Function 4 */
void cf05 (double *, double *, int , double *,double *, int); /* Composition Function 5 */
void cf06 (double *, double *, int , double *,double *, int); /* Composition Function 6 */
void cf07 (double *, double *, int , double *,double *, int); /* Composition Function 7 */
void cf08 (double *, double *, int , double *,double *, int); /* Composition Function 8 */
void cf09 (double *, double *, int , double *,double *, int *, int); /* Composition Function 7 */
void cf10 (double *, double *, int , double *,double *, int *, int); /* Composition Function 8 */
void shiftfunc (double*,double*,int,double*);
void rotatefunc (double*,double*,int, double*);
void sr_func (double *, double *, int, double*, double*, double, int, int); /* shift and rotate */
void asyfunc (double *, double *x, int, double);
void oszfunc (double *, double *, int);
void cf_cal(double *, double *, int, double *,double *,double *,double *,int);
void cec17_test_func(double *, double *,int,int,int);
void mexFunction (int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[])
{
int m, n,func_num;
double *f, *x;
if ((nrhs < 2) || (nlhs < 1))
{
mexPrintf ("usage: f = cec17_func(x, func_num);\n");
mexErrMsgTxt ("example: f= cec17_func([3.3253000e+000, -1.2835000e+000]', 1);");
}
n = mxGetM (prhs[0]);
if (!(n==2||n==10||n==30||n==50||n==100))
{
mexPrintf ("usage: f = cec17_func(x, func_num);\n");
mexErrMsgTxt ("Error: Test functions are only defined for D=2,10,30,50,100.");
}
m = mxGetN (prhs[0]);
x = mxGetPr (prhs[0]);
func_num= (int)*mxGetPr (prhs[1]);
if (func_num>30)
{
mexPrintf ("usage: f = cec17_func(x, func_num);\n");
mexErrMsgTxt ("Error: There are only 30 test functions in this test suite!");
}
plhs[0] = mxCreateDoubleMatrix (1, m, mxREAL);
f = mxGetPr (plhs[0]);
cec17_test_func(&x[0], &f[0], n,m,func_num);
}
void cec17_test_func(double *x, double *f, int nx, int mx,int func_num)
{
int cf_num=10,i,j;
if (ini_flag==1)
{
if ((n_flag!=nx)||(func_flag!=func_num))
{
ini_flag=0;
}
}
if (ini_flag==0)
{
FILE *fpt;
char FileName[256];
free(M);
free(OShift);
free(y);
free(z);
free(x_bound);
y=(double *)malloc(sizeof(double) * nx);
z=(double *)malloc(sizeof(double) * nx);
x_bound=(double *)malloc(sizeof(double) * nx);
for (i=0; i<nx; i++)
x_bound[i]=100.0;
if (!(nx==2||nx==10||nx==20||nx==30||nx==50||nx==100))
{
printf("\nError: Test functions are only defined for D=2,10,20,30,50,100.\n");
}
if (nx==2&&((func_num>=17&&func_num<=22)||(func_num>=29&&func_num<=30)))
{
printf("\nError: hf01,hf02,hf03,hf04,hf05,hf06,cf07&cf08 are NOT defined for D=2.\n");
}
/* Load Matrix M*/
sprintf(FileName, "input_data/M_%d_D%d.txt", func_num,nx);
fpt = fopen(FileName,"r");
if (fpt==NULL)
{
printf("\n Error: Cannot open input file for reading \n");
}
if (func_num<20)
{
M=(double*)malloc(nx*nx*sizeof(double));
if (M==NULL)
printf("\nError: there is insufficient memory available!\n");
for (i=0; i<nx*nx; i++)
{
fscanf(fpt,"%lf",&M[i]);
}
}
else
{
M=(double*)malloc(cf_num*nx*nx*sizeof(double));
if (M==NULL)
printf("\nError: there is insufficient memory available!\n");
for (i=0; i<cf_num*nx*nx; i++)
{
fscanf(fpt,"%lf",&M[i]);
}
}
fclose(fpt);
/* Load shift_data */
sprintf(FileName, "input_data/shift_data_%d.txt", func_num);
fpt = fopen(FileName,"r");
if (fpt==NULL)
{
printf("\n Error: Cannot open input file for re
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
IEEE CEC,全称是IEEE Congress on Evolutionary Computation,可以翻译为,IEEE进化计算会议。自2005年开始,每年举办一次。IEEE CEC benchmarks,是主办方发布的标准测试算例(以下简称,CEC算例)。 CEC2014年及CEC2017年测试集,matlab版本; 该测试集是用于演化算法性能测试的基准函数,CEC2014的函数组成可参见CEC2014的介绍文档“Definitions of CEC2014 benchmark suite Part A”,调用方法可参照CEC2014 MATLAB示例代码。
资源推荐
资源详情
资源评论
收起资源包目录
CEC2014 2017测试集.7z (5个子文件)
CEC2014 2017测试集
cec14_func.mexw32 32KB
cec14_func.cpp 33KB
cec14_func.mexw64 32KB
cec17_func.cpp 41KB
cec17_func.mexw64 51KB
共 5 条
- 1
资源评论
王也-王道长
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功