00001
00020
00021
00022
00023
00024 # include <stdio.h>
00025 # include <stdlib.h>
00026
00027 #define _MAIN
00028
00029 #include "cec2005.h"
00030 #include "random.h"
00031 #include "srandom.h"
00032
00033 int main (int argc, char**argv)
00034 {
00035 int i;
00036 long double *x;
00037 long double f;
00038 Random random(new SRandom(12345679));
00039
00040 if (argc<3)
00041 {
00042 fprintf(stderr,"\n Usage ./%s nfunc nreal\n", argv[0]);
00043 exit(0);
00044 }
00045
00046
00047 int nfunc = (int)atoi(argv[1]);
00048 int nreal = (int)atoi(argv[2]);
00049
00050 if (nfunc<1)
00051 {
00052 fprintf(stderr,"\n Wrong value of 'nfunc' entered\n");
00053 exit(0);
00054 }
00055 if (nreal!=2 && nreal!=10 && nreal!=30 && nreal!=50)
00056 {
00057 fprintf(stderr,"\n Wrong value of 'nreal' entered, only 2, 10, 30, 50 variables are supported\n");
00058 exit(0);
00059 }
00060 printf("\n Number of basic functions = %d",nfunc);
00061 printf("\n Number of real variables = %d",nreal);
00062
00063 init_cec2005(&random, nfunc, nreal);
00064
00065
00066 x = (long double *)malloc(nreal*sizeof(long double));
00067
00068 for (i=0; i<nreal; i++)
00069 {
00070 printf("\n Enter the value of variable x[%d] : ",i+1);
00071 scanf("%Lf",&x[i]);
00072 }
00073
00074 f = eval_cec2005( (const tGen *) x, nreal);
00075 printf("\n Objective value = %1.15LE",f);
00076
00077
00078 finish_cec2005();
00079
00080 printf("\nRoutine exited without any error.\n");
00081 return(1);
00082 }