基于遗传算法优化神经网络结构源程序

基于遗传算法优化神经网络结构源程序

ID:34629441

大小:40.00 KB

页数:11页

时间:2019-03-08

基于遗传算法优化神经网络结构源程序_第1页
基于遗传算法优化神经网络结构源程序_第2页
基于遗传算法优化神经网络结构源程序_第3页
基于遗传算法优化神经网络结构源程序_第4页
基于遗传算法优化神经网络结构源程序_第5页
资源描述:

《基于遗传算法优化神经网络结构源程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、基于遗传算法优化神经网络结构源程序:#include#include#include#include#include#include#include"graph.c"#include"operator.c"/*宏定义*/#definePOP_SIZE20#defineS_RATE0.4#defineM_RATE0.01#defineI_MAX5#defineH_MAX20#defineO_MAX5#def

2、ineP_MAX100#defineMAX_G_LENGTH100#defineGX1360#defineGY166#defineGX2360#defineGY2257#defineGXR250#defineGYR100#defineGSTEP2/*全局变量*/unsignedchargene[POP_SIZE][MAX_G_LENGTH];/*个体遗传基因*/unsignedchari_unit[I_MAX],h_unit[H_MAX],o_unit[O_MAX];unsignedcharp_i_unit[P_MA

3、X][I_MAX];unsignedcharp_o_unit[P_MAX][O_MAX];doublefitness[POP_SIZE];doublemax_fit,avg_fit;inti_num,h_num,o_num,t_num;intp_num;intg_length;longintcalc_g_length(){inti;longintnum;num=0;for(i=1;i<=h_num;i++)num=num+i_num+(i-1);num=num+o_num*(i_num+h_num);return(n

4、um);}voidset_network(){inti,ok;longintwork;charchoice[2];settextstyle(0,0,4);gprintf(215,15,4,0,"GA-NN");setcolor(9);disp_hz24("遗传优化神经网络结构",170,50,25);disp_hz16("同济大学计算机系王小平",150,100,20);disp_hz16("=========确定网络结点数==========",10,150,20);ok=1;while(ok==1){setcol

5、or(9);disp_hz16("输入结点数:",10,180,20);gscanf(300,180,9,15,3,"%s",choice);i_num=atoi(choice);setcolor(9);disp_hz16("隐结点数:",10,210,20);gscanf(300,210,15,15,3,"%s",choice);h_num=atoi(choice);setcolor(9);disp_hz16("输出结点数:",10,240,20);gscanf(300,240,15,0,4,"%s",choice

6、);o_num=atoi(choice);t_num=i_num+h_num+o_num;work=calc_g_length();if(work>MAX_G_LENGTH)disp_hz16("结点数太多,请重输入。",10,250,20);else{g_length=(int)work;setcolor(9);disp_hz16("ok?1:no,2:yes",10,270,20);gscanf(300,270,4,0,4,"%s",choice);ok=atoi(choice);}}}voidset_probl

7、em(){inti,j;FILE*fopen(),*fpt;if((fpt=fopen("\ga\sample","r"))==NULL)exit(-1);else{fscanf(fpt,"%d",&p_num);for(i=1;i<=p_num;i++){ for(j=1;j<=i_num;j++)fscanf(fpt,"%d",&p_i_unit[i-1][j-1]); for(j=1;j<=o_num;j++) fscanf(fpt,"%d",&p_o_unit[i-1][j-1]);}fclose(fpt

8、);}}voidg_draw_frame(x1,y1,x2,y2,c1,c2,c3,c4,text)intx1,y1,x2,y2,c1,c2,c3,c4;char*text;{intn,x3;g_rectangle(x1,y1,x2,y2,c1,1);g_rectangle(x1,y1,x2,y2,c2,0);g_rectangle(x1,y1

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。