这是linux下的进化计算的源代码。 === === === === === === === === === === === ===== check latest news at http:

源代码在线查看: t-mge1bit.cpp

软件大小: 1452 K
上传用户: dragoncircle
关键词: latest linux check http
下载地址: 免注册下载 普通下载 VIP

相关代码

				//-----------------------------------------------------------------------------				// t-eoMGE.cpp				//-----------------------------------------------------------------------------								#ifdef HAVE_CONFIG_H				#include 				#endif								#ifndef __GNUG__				// to avoid long name warnings				#pragma warning(disable:4786)				#endif // __GNUG__								#include "eo"				#include "ga/eoBitOp.h"				#include "RoyalRoad.h"								// Viri				#include "VirusOp.h"				#include "eoVirus.h"				#include "eoInitVirus.h"								//-----------------------------------------------------------------------------								typedef eoVirus Chrom;								//-----------------------------------------------------------------------------								int main()				{				  const unsigned POP_SIZE = 10, CHROM_SIZE = 12;				  unsigned i;				  eoBooleanGenerator gen;								  // the populations:				  eoPop pop;								  // Evaluation				  RoyalRoad rr( 8 );				  eoEvalFuncCounter eval( rr );								  eoInitVirus1bit random(CHROM_SIZE, gen);				  for (i = 0; i < POP_SIZE; ++i) {				      Chrom chrom;				      random(chrom);				      eval(chrom);				      pop.push_back(chrom);				  }								  std::cout 				  for (i = 0; i < pop.size(); ++i)				    std::cout 								  // selection				  eoStochTournamentSelect lottery(0.9 );								  // breeder				  VirusShiftMutation vm;				  VirusTransmission vt;				  VirusBitFlip vf;				  eoUBitXover xover;				  eoProportionalOp propSel;				  eoGeneralBreeder breeder( lottery, propSel );				  propSel.add(vm, 0.8);				  propSel.add(vf, 0.05);				  propSel.add(vt, 0.05);				  propSel.add(xover, 0.1);								  // Replace a single one				  eoCommaReplacement replace;								  // Terminators				  eoGenContinue continuator1(10);				  eoFitContinue continuator2(CHROM_SIZE);				  eoCombinedContinue continuator(continuator1, continuator2);				  eoCheckPoint checkpoint(continuator);				  eoStdoutMonitor monitor;				  checkpoint.add(monitor);				  eoSecondMomentStats stats;				  eoPopStat dumper( 10 );				  monitor.add(stats);				  checkpoint.add(dumper);				  checkpoint.add(stats);								  // GA generation				  eoEasyEA ea(checkpoint, eval, breeder, replace);								  // evolution				  try {				      ea(pop);				  } catch (std::exception& e) {				      std::cerr 				      exit(EXIT_FAILURE);				  }								  std::cout 				  for (i = 0; i < pop.size(); ++i)				      std::cout 								  std::cout 				  return EXIT_SUCCESS;				}								//-----------------------------------------------------------------------------																// Local Variables:				// mode: C++				// c-file-style: "Stroustrup"				// End:							

相关资源