/
mkosh0
/
CEC_Remastered
Обзор
Документация
Войти
/
mkosh0
/
CEC_Remastered
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
main.cpp
75 строк
1 KB
mkosh0
Начало
04 мар 2026, 12:03
Верифицирован
04 мар 2026, 12:03
35d779d
Код
Авторство
О чём код?
/* CEC17 Test Function Suite for Single Objective Optimization Noor Awad (email: noor0029@ntu.edu.sg) Sep. 10th 2016 */ #include <WINDOWS.H> #include <stdio.h> #include <math.h> #include <malloc.h> void cec17_test_func(double *, double *,int,int,int); double *OShift,*M,*y,*z,*x_bound; int ini_flag=0,n_flag,func_flag,*SS; void main() { int i,j,k,n,m,func_num; double *f,*x; FILE *fpt; char FileName[30]; m=2; n=10; x=(double *)malloc(m*n*sizeof(double)); f=(double *)malloc(sizeof(double) * m); for (i = 0; i < 30; i++) { func_num=i+1; 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 reading \n"); } if (x==NULL) printf("\nError: there is insufficient memory available!\n"); for(k=0;k<n;k++) { fscanf(fpt,"%Lf",&x[k]); /*printf("%Lf\n",x[k]);*/ } fclose(fpt); for (j = 0; j < n; j++) { x[1*n+j]=0.0; /*printf("%Lf\n",x[1*n+j]);*/ } for (k = 0; k < 1; k++) { cec17_test_func(x, f, n,m,func_num); for (j = 0; j < 2; j++) { printf(" f%d(x[%d]) = %Lf,",func_num,j+1,f[j]); } printf("\n"); } } free(x); free(f); free(y); free(z); free(M); free(OShift); free(x_bound); }