• Main Page
  • Modules
  • Classes
  • Files
  • File List

D:/Projekt/ECF_trunk/examples/CEC/cec14-c-code/main.cpp

00001 /*
00002   CEC14 Test Function Suite for Single Objective Optimization
00003   Jane Jing Liang (email: liangjing@zzu.edu.cn; liangjing@pmail.ntu.edu.cn) 
00004   Dec. 12th 2013
00005 */
00006 
00007 #include <WINDOWS.H>    
00008 #include <stdio.h>
00009 #include <math.h>
00010 #include <malloc.h>
00011 
00012 
00013 void cec14_test_func(double *, double *,int,int,int);
00014 
00015 double *OShift,*M,*y,*z,*x_bound;
00016 int ini_flag=0,n_flag,func_flag,*SS;
00017 
00018 
00019 void main()
00020 {
00021     int i,j,k,n,m,func_num;
00022     double *f,*x;
00023     FILE *fpt;
00024     char FileName[30];
00025     m=2;
00026     n=10;
00027     x=(double *)malloc(m*n*sizeof(double));
00028     f=(double *)malloc(sizeof(double)  *  m);
00029     for (i = 0; i < 30; i++)
00030     {
00031         func_num=i+1;
00032         sprintf(FileName, "input_data/shift_data_%d.txt", func_num);
00033         fpt = fopen(FileName,"r");
00034         if (fpt==NULL)
00035         {
00036             printf("\n Error: Cannot open input file for reading \n");
00037         }
00038         
00039         if (x==NULL)
00040             printf("\nError: there is insufficient memory available!\n");
00041 
00042         for(k=0;k<n;k++)
00043         {
00044                 fscanf(fpt,"%Lf",&x[k]);
00045                 /*printf("%Lf\n",x[k]);*/
00046         }
00047 
00048         fclose(fpt);
00049 
00050             for (j = 0; j < n; j++)
00051             {
00052                 x[1*n+j]=0.0;
00053                 /*printf("%Lf\n",x[1*n+j]);*/
00054             }
00055         
00056         
00057         for (k = 0; k < 1; k++)
00058         {
00059             cec14_test_func(x, f, n,m,func_num);
00060             for (j = 0; j < 2; j++)
00061             {
00062                 printf(" f%d(x[%d]) = %Lf,",func_num,j+1,f[j]);
00063             }
00064             printf("\n");
00065         }
00066     
00067     }
00068     free(x);
00069     free(f);
00070     free(y);
00071     free(z);
00072     free(M);
00073     free(OShift);
00074     free(x_bound);
00075 }
00076 
00077 

Generated on Tue Nov 4 2014 13:04:31 for ECF by  doxygen 1.7.1