JackCrum 2020-01-29 21:14 采纳率: 100%

# Matlab之Cec13测试函数入口参数的定义

1.今天在做优化算法的代码分析时，需要调用CEC13测试函数，按照官方给定

2.附上代码：

``````/*
CEC13 Test Function Suite
Jane Jing Liang (email: liangjing@zzu.edu.cn)
14th Feb. 2013
1. Run the following command in Matlab window:
mex cec13_func.cpp -DWINDOWS
2. Then you can use the test functions as the following example:
f = cec13_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;

#define INF 1.0e99
#define EPS 1.0e-14
#define E  2.7182818284590452353602874713526625
#define PI 3.1415926535897932384626433832795029
// Brief:这部分申明了mex文件中需要用到的函数。其中包括：差值函数、
void sphere_func (double *, double *, int , double *,double *, int); /* Sphere */
void ellips_func(double *, double *, int , double *,double *, int); /* Ellipsoidal */
void bent_cigar_func(double *, double *, int , double *,double *, int); /* Discus */
void discus_func(double *, double *, int , double *,double *, int);  /* Bent_Cigar */
void dif_powers_func(double *, double *, int , double *,double *, int);  /* Different Powers */
void rosenbrock_func (double *, double *, int , double *,double *, int); /* Rosenbrock's */
void schaffer_F7_func (double *, double *, int , double *,double *, int); /* Schwefel's F7 */
void ackley_func (double *, double *, int , double *,double *, int); /* Ackley's */
void rastrigin_func (double *, double *, int , double *,double *, int); /* Rastrigin's  */
void step_rastrigin_func (double *, double *, int , double *,double *, int); /* Noncontinuous Rastrigin's  */
void weierstrass_func (double *, double *, int , double *,double *, int); /* Weierstrass's  */
void griewank_func (double *, double *, int , double *,double *, int); /* Griewank's  */
void schwefel_func (double *, double *, int , double *,double *, int); /* Schwefel's */
void katsuura_func (double *, double *, int , double *,double *, int); /* Katsuura */
void bi_rastrigin_func (double *, double *, int , double *,double *, int); /* Lunacek Bi_rastrigin Function */
void grie_rosen_func (double *, double *, int , double *,double *, int); /* Griewank-Rosenbrock  */
void escaffer6_func (double *, double *, int , double *,double *, int); /* Expanded Scaffer’s F6  */
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 shiftfunc (double*,double*,int,double*);
void rotatefunc (double*,double*,int, double*);
void asyfunc (double *, double *x, int, double);
void oszfunc (double *, double *, int);
void cf_cal(double *, double *, int, double *,double *,double *,double *,int);
void test_func(double *, double *,int,int,int);

*******%此处省略大概800行均为函数描写

``````

3.有做这方面的大佬还望不吝赐教，万分感谢！需要代码分享的也可以在楼下评论。

• 写回答

#### 2条回答默认 最新

• weixin_43458990 2020-04-23 20:49
关注

我傻了，我今天也在做，老师让我写一个PSO算法出来，然后给了我CEC14让我来测试，不同的是我用的是C 楼主啥年级啊，可以交流下

本回答被题主选为最佳回答 , 对您是否有帮助呢?
评论

• 已采纳回答 1月13日

#### 悬赏问题

• ¥15 CCF-CSP 2023 第三题 解压缩(50％)
• ¥30 comfyui openpose报错
• ¥20 Wpf Datarid单元格闪烁效果的实现
• ¥15 图像分割、图像边缘提取
• ¥15 sqlserver执行存储过程报错
• ¥100 nuxt、uniapp、ruoyi-vue 相关发布问题
• ¥15 浮窗和全屏应用同时存在，全屏应用输入法无法弹出
• ¥100 matlab2009 32位一直初始化
• ¥15 Expected type 'str | PathLike[str]…… bytes' instead
• ¥15 三极管电路求解，已知电阻电压和三级关放大倍数