ECF 1.5
main.cpp
1/*
2 CEC14 Test Function Suite for Single Objective Optimization
3 Jane Jing Liang (email: liangjing@zzu.edu.cn; liangjing@pmail.ntu.edu.cn)
4 Dec. 12th 2013
5*/
6
7#include <WINDOWS.H>
8#include <stdio.h>
9#include <math.h>
10#include <malloc.h>
11
12
13void cec14_test_func(double *, double *,int,int,int);
14
15double *OShift,*M,*y,*z,*x_bound;
16int ini_flag=0,n_flag,func_flag,*SS;
17
18
19void main()
20{
21 int i,j,k,n,m,func_num;
22 double *f,*x;
23 FILE *fpt;
24 char FileName[30];
25 m=2;
26 n=10;
27 x=(double *)malloc(m*n*sizeof(double));
28 f=(double *)malloc(sizeof(double) * m);
29 for (i = 0; i < 30; i++)
30 {
31 func_num=i+1;
32 sprintf(FileName, "input_data/shift_data_%d.txt", func_num);
33 fpt = fopen(FileName,"r");
34 if (fpt==NULL)
35 {
36 printf("\n Error: Cannot open input file for reading \n");
37 }
38
39 if (x==NULL)
40 printf("\nError: there is insufficient memory available!\n");
41
42 for(k=0;k<n;k++)
43 {
44 fscanf(fpt,"%Lf",&x[k]);
45 /*printf("%Lf\n",x[k]);*/
46 }
47
48 fclose(fpt);
49
50 for (j = 0; j < n; j++)
51 {
52 x[1*n+j]=0.0;
53 /*printf("%Lf\n",x[1*n+j]);*/
54 }
55
56
57 for (k = 0; k < 1; k++)
58 {
59 cec14_test_func(x, f, n,m,func_num);
60 for (j = 0; j < 2; j++)
61 {
62 printf(" f%d(x[%d]) = %Lf,",func_num,j+1,f[j]);
63 }
64 printf("\n");
65 }
66
67 }
68 free(x);
69 free(f);
70 free(y);
71 free(z);
72 free(M);
73 free(OShift);
74 free(x_bound);
75}
76
77