/*
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
王也-王道长
- 粉丝: 1
- 资源: 4
最新资源
- opencv-4.10.0-vs2022-x86 音视频研发
- 2015-2016中国手机应用商店年度报告.pdf
- 2015-2016中国信息时代新消费方式专题报告.pdf
- 2015Q3Q4中国TMT报告.pdf
- 2015Q4中国移动社交通信季度报告.pdf
- springboot学生作业管理系统.zip
- 基于Python+Flask开发的Android测试工具
- 2015本地出行类移动应用行业分析报告.pdf
- 2015埃维诺技术展望.pdf
- 解决ole DB 保存nvarchar字符乱码问题
- 2015国产电影发行市场白皮书.pdf
- 2015大地影院媒体生态圈价值报告(完整版).pdf
- 河北省雄安新区(马蹄湾村)航空高光谱遥感应用数据集下载
- 2015美国新媒体研究报告(皮尤研究中心).pdf
- 2015年1-4月中国移动互联网行业发展分析报告.pdf
- 2015年1月至11月微博移动端用户研究报告.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈