欢迎来到天天文库
浏览记录
ID:38427228
大小:33.00 KB
页数:10页
时间:2019-06-12
《遗传算法c源代码一》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、遗传算法c源代码破菜筐2006-03-2221:45发表/*-----------------------------------------------------------------------*
2、
3、
4、 Robotics95 -- FinalCourseProject
5、
6、
7、
8、
9、 By: ZivPollack & OmriWeisman
10、
11、
12、
13、 NNUGA-NeuralNetworkUsingGeneticAlgorithms
14、
15、
16、
17、*-----------------------------------------------------------------------*//**Filename:nnuga.c**ThisprogramisanimplementationofaNeuralNetwork(NN)whichlearnsusing*GeneticAlgorithms(GA).ItrunsfromaTkshell
18、.**Itreadspointsfromafileandcreatesanoutputfilewhichdescribes*pointsthatcorrespondtolinesthatseperatetheplainintoseveral*regions,regionswheretheNN'soutputwillbetrue,andaregions*wheretheNN'soutputwillbefalse.**/#include#include#include/*NN
19、related*/#defineNUM2 /*Numberofinputnodes*/#defineLIMIT150 /*Maximumnumberofinputsthesystemcanhandle*/#defineSESSIONS500 /*Numberoftrainingsessionsthatwe'llputthesystemthrough*//*GArelated*/#definePOPS 10 /*Numberofpopulations*/#defineSIZE 25 /*Size
20、ofvectorinthegeneticalgorithms*/#defineMAXPOP 60 /*Sizeofpopulation*/#defineBESTPOP4 /*Numberofindividualstakenfromthebest*/#defineSELPOP 8 /*SELPOP-BESTPOP=Numberofpeopleselectedrandomlyoneachgen.*/#defineNEWPOP 18 /*NEWPOP-SELPOP=Numberofnewpeople,created
21、randomlyoneachgen.*/#defineMUT1 25 /*MUT1-NEWPOP=Numberofmutationsinthefirstmutationgroup*/#defineMIXGEN 10 /*Numberofgenerationsbetweenpopulationmixing*/typedefstruct{ floatp[NUM];}vector;/*NNrelated*/vectortest[LIMIT],w1,w2,w3,w4,w5,w6;inthits[LIMIT],total;fl
22、oatw7[6];intb1,b2,b3,b4,b5,b6,b7;/*GArelated*/floatpop[POPS][MAXPOP][SIZE];intscore[POPS][MAXPOP];/*-------------------------------
此文档下载收益归作者所有