资源简介
遗传算法源代码,希望对大家有帮助

代码片段和文件信息
#include
#include
#include
#include
#include
#include
#ifndef RAND_MAX
#define RAND_MAX 32767
#endif;
#ifndef MAX_NUMBER
#define MAX_NUMBER 0xffffff
#endif;
struct Solution{
int *a;
int *Z;
int *ZDelta;
double F;
double **SF;
double **SFDelta;
double *WCV;
double **C;
int num;
double TWCV;
double TWCVDelta;
double **d;
double e;
int *change;
double *dmax;
double *dmin;
int *kmin;
int *kmax;
double *dsum;
int used;
};
void FGKA();
void Init();
void Selection();
void Mutation();
void KMO();
void Eval(int);
void AccumulateUpdate(int int int int);
void IncrementalUpdate(int);
void CopySolution(struct Solution * struct Solution *);
double* gather(double*int);
int Distribution(double* int);
char* getline(FILE*);
int LoadData (const char*);
int Export(const char*);
int* match1;
int* match2;
double **X; //Pattern
struct Solution *S;
struct Solution SO;
int K = 0; // Cluster number
int N = 0; // Pattern number
int D = 0; // Feature number
int M = 0; // Population number
double TWCV;
double TWCVMax;
int G = 0; // Maximum number of Generation
float mp; //mutation Probability
int *origin;
FILE* outputfile;
void main(int argcchar **argv)
{
char filename[30];
printf(“\nPlease input the file name for processing: “);
scanf(“%s“ filename);
strcat(filename“\0“);
printf(“\nPlease enter the number of Clusters: “);
scanf(“%d“&K);
printf(“\nPlease enter the number of Populations: “);
scanf(“%d“&M);
printf(“\nPlease enter the number of maximum generations: “);
scanf(“%d“&G);
printf(“\nPlease enter the mutation probability: “);
scanf(“%f“&mp);
if ( LoadData(filename) == -1 ) exit(1);
// for(i=0; i<10; i++)
FGKA();
Export(filename);
free(X);
}
void FGKA()
{
int tim1 tim2;
int n i m;
tim1 = time(0);
SO.TWCV = MAX_NUMBER;
Init();
for(i=0; i {
Selection();
Mutation();
KMO();
for(m=0; m {
if(SO.TWCV > S[m].TWCV)
{
SO.TWCV = S[m].TWCV;
for(n=0; n SO.a[n] = S[m].a[n];
}
}
tim2 = time(0);
printf(“iteration %d\t%f\t%d\n“i SO.TWCV tim2 - tim1);
}
// fprintf(outputfile“%f\n“ SO.TWCV);
// printf(“TWCV: %f\t%f\n“ Twcv(SO.a) SO.TWCV);
tim2 = time(0);
printf(“%d“ tim2 - tim1);
free(S);
}
void Init()
{
int n m k d;
TWCVMax = 0;
S = (struct Solution*)malloc((size_t)M*sizeof(struct Solution));
match1 = (int*)malloc((size_t)M*sizeof(int));
match2 = (int*)malloc((size_t)M*sizeof(int));
// srand( (unsigned)time( NULL ));
srand(100);
for(m = 0; m < M; m++)
{
SO.a = (int*)malloc((size_t)N*sizeof(int));
S[m].a = (int*)malloc((size_t)N*sizeof(int));
S[m].Z = (int*)malloc((size_t)K*sizeof(int));
S[m].ZDelta = (int*)malloc((size_t)K*sizeof(int));
S[m].WCV = (double*)malloc((size_t)K*sizeof(d
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4270 1996-05-30 14:50 遗传算法\源代码\新建文件夹\BP.C
文件 155 2005-03-01 16:24 遗传算法\源代码\新建文件夹\AVERAGE.C
文件 2435 1996-05-30 14:52 遗传算法\源代码\新建文件夹\CROSSOVE.C
文件 1842 1996-03-08 01:32 遗传算法\源代码\新建文件夹\DRAWBP.C
文件 5554 1995-08-29 04:52 遗传算法\源代码\新建文件夹\EGAVGA.BGI
文件 2071 1996-05-30 14:53 遗传算法\源代码\新建文件夹\FITNESS.C
文件 13081 1996-05-30 15:29 遗传算法\源代码\新建文件夹\GA.C
文件 94624 1996-05-30 15:30 遗传算法\源代码\新建文件夹\GA.EXE
文件 38056 1996-05-30 15:02 遗传算法\源代码\新建文件夹\GA.IDE
文件 257 1996-02-23 11:52 遗传算法\源代码\新建文件夹\GAUSSIAN.C
文件 1063 1996-05-30 14:57 遗传算法\源代码\新建文件夹\GETW.C
文件 579 1996-03-05 11:59 遗传算法\源代码\新建文件夹\INITIALI.C
文件 12461 1996-02-22 14:10 遗传算法\源代码\新建文件夹\IRISGA.DAT
文件 156 2000-10-29 12:45 遗传算法\源代码\新建文件夹\IRISGA.RUN
文件 240 1996-03-05 11:59 遗传算法\源代码\新建文件夹\MAIN.C
文件 198 1996-03-05 12:00 遗传算法\源代码\新建文件夹\MAXIMUM.C
文件 170 1996-03-05 12:01 遗传算法\源代码\新建文件夹\MINIMIAL.C
文件 1039 1996-05-30 14:58 遗传算法\源代码\新建文件夹\MUTATE.C
文件 717 1996-05-30 14:58 遗传算法\源代码\新建文件夹\ONECROSS.C
文件 9739 2000-10-29 12:46 遗传算法\源代码\新建文件夹\OUTPUT.TXT
文件 2500 1996-05-30 14:59 遗传算法\源代码\新建文件夹\SELECTIO.C
文件 919 1996-05-30 14:59 遗传算法\源代码\新建文件夹\TWOCROSS.C
文件 687 1996-05-30 15:00 遗传算法\源代码\新建文件夹\UNICROSS.C
文件 495 1996-02-26 15:45 遗传算法\源代码\新建文件夹\VARIANCE.C
文件 407 2000-10-29 12:46 遗传算法\源代码\新建文件夹\WEIGHTS.TXT
文件 16493 2005-03-04 16:45 遗传算法\源代码\IGKA\IGKA.c
文件 666 2005-03-04 16:45 遗传算法\源代码\IGKA\chodata.txt
目录 0 2007-10-03 16:47 遗传算法\源代码\新建文件夹
目录 0 2007-10-03 16:47 遗传算法\源代码\IGKA
目录 0 2007-10-03 16:47 遗传算法\源代码
............此处省略4个文件信息
- 上一篇:HScan_v1.2汉化
- 下一篇:The Tao fr
amework 2.1.0
相关资源
- QGA 量子遗传算法
- 基于遗传算法的排课系统
- 遗传算法的M文件
- 遗传算法PPT(Genetic_Algorithms.ppt)
- 遗传算法的堆石料非线性本构模型参
- 遗传算法越野小车unity5.5
- 车间布局遗传算法
- 遗传算法论文11篇
- 基于遗传算法的立体车库车位调度研
- 遗传算法解决TSP旅行商问题程序开源
- 基于GA-ELM的瓦斯涌出量预测
- 5种多旅行商问题(MTSP)的遗传算法
- 人工智能和遗传算法的结合推荐必读
- 遗传算法0-1背包问题论文
- 改进的k_均值聚类排挤小生境遗传算法
- 基于遗传优化的无刷直流电机模糊控
- GA+ICP代码
- 计算智能大作业合集
- 遗传算法与工程优化_玄光男_程润伟
- NSGA和NSGAII算法
- 群体智能.ppt
- Qt写的遗传算法加画图程序
- 遗传算法优化支持向量机算法
- 遗传算法原理及应用--选择交叉变异算
- 使用神经网络与遗传算法的小游戏
- 遗传算法的适应度函数构造
- 车间调度遗传算法程序
- 遗传算法及其代码实现
- 遗传算法的基本理论与应用
- 遗传算法原理及应用
评论
共有 条评论