亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ex10.c

?? 遺傳算法的源程序例子
?? C
字號:
/* ----------------------------------------------------------------------------  ex10.C  mbwall 10apr95  Copyright (c) 1995-1996  Massachusetts Institute of Technology DESCRIPTION:   Sample program that illustrates how to use a distance function to do speciation.  This example does both gene-based and phenotype-based distancecalculations.  The differences are quite interesting.  Also, the length of thebit string (i.e. the size of the search space) is also a significant factor inthe performance of the speciation methods.   Notice that Goldberg describes fitness scaling speciation in the context ofa simple genetic algorithm.  You can try using it with a steady-state algorithm, but you'll get bogus results unless you modify the algorithm.---------------------------------------------------------------------------- */#include <stdlib.h>#include <stdio.h>#include <iostream.h>#include <fstream.h>#include <math.h>#include <ga/ga.h>#define USE_RAW_SINE#ifndef M_PI#define M_PI            3.14159265358979323846#endif#define NBITS     8#ifdef USE_RAW_SINE#define FUNCTION  Function1#define MIN_VALUE 0#define MAX_VALUE 5#else#define FUNCTION  Function2#define MIN_VALUE -100#define MAX_VALUE 100#endiffloat Function1(float);float Function2(float);float Objective(GAGenome &);float BitDistance(const GAGenome & a, const GAGenome & b);float PhenotypeDistance(const GAGenome & a, const GAGenome & b);intmain(int argc, char **argv){  cout << "Example 10\n\n";  cout << "This program uses sharing to do speciation.  The objective\n";  cout << "function has more than one optimum, so different genomes\n";  cout << "may have equally high scores.  Speciation keeps the population\n";  cout << "from clustering at one optimum.\n";  cout << "  Both gene-wise and phenotype-wise distance functions are used.\n";  cout << "  Populations from all three runs are written to the files \n";  cout << "pop.nospec.dat, pop.genespec.dat and pop.phenespec.dat.  The\n";  cout << "function is written to the file sinusoid.dat\n\n";  cout.flush();// See if we've been given a seed to use (for testing purposes).  When you// specify a random seed, the evolution will be exactly the same each time// you use that seed number.  for(int ii=1; ii<argc; ii++) {    if(strcmp(argv[ii++],"seed") == 0) {      GARandomSeed((unsigned int)atoi(argv[ii]));    }  }  int i;  char filename[32] = "sinusoid.dat";  char popfilename1[32] = "pop.nospec.dat";  char popfilename2[32] = "pop.genespec.dat";  char popfilename3[32] = "pop.phenespec.dat";  ofstream outfile;// Create a phenotype for two variables.  The number of bits you can use to// represent any number is limited by the type of computer you are using.  In// this case, we use 16 bits to represent a floating point number whose value// can range from the minimum to maximum value as defined by the macros.  GABin2DecPhenotype map;  map.add(NBITS, MIN_VALUE, MAX_VALUE);// Create the template genome using the phenotype map we just made.  GABin2DecGenome genome(map, Objective);// Now create the GA using the genome and set all of the parameters.// You'll get different results depending on the type of GA that you use.  The// steady-state GA tends to converge faster (depending on the type of replace-// ment method you specify).    GASimpleGA ga(genome);  ga.set(gaNpopulationSize, 200);  ga.set(gaNnGenerations, 50);  ga.set(gaNpMutation, 0.001);  ga.set(gaNpCrossover, 0.9);  ga.parameters(argc, argv);// Do the non-speciated and write to file the best-of-generation.  cout << "running with no speciation (fitness proportionate scaling)...\n";  cout.flush();  GALinearScaling lin;  ga.scaling(lin);  ga.evolve();  genome = ga.statistics().bestIndividual();  cout << "the ga found an optimum at the point "<<genome.phenotype(0)<<endl;  outfile.open(popfilename1, (ios::out | ios::trunc));  if(outfile.fail()){    cerr << "Cannot open " << popfilename1 << " for output.\n";    exit(1);  }  for(i=0; i<ga.population().size(); i++){    outfile<<((GABin2DecGenome&)(ga.population().individual(i))).phenotype(0);    outfile << "\t";    outfile << ga.population().individual(i).score() << "\n";  }  outfile.close();// Now do speciation using the gene-wise distance function  cout << "running the ga with speciation (sharing using bit-wise)...\n";  cout.flush();  GASharing bitSharing(BitDistance);  ga.scaling(bitSharing);  ga.evolve();  genome = ga.statistics().bestIndividual();  cout << "the ga found an optimum at the point "<<genome.phenotype(0)<<endl;  outfile.open(popfilename2, (ios::out | ios::trunc));  if(outfile.fail()){    cerr << "Cannot open " << popfilename2 << " for output.\n";    exit(1);  }  for(i=0; i<ga.population().size(); i++){    outfile<<((GABin2DecGenome&)(ga.population().individual(i))).phenotype(0);    outfile << "\t";    outfile << ga.population().individual(i).score() << "\n";  }  outfile.close();// Now do speciation using the phenotype-wise distance function  cout << "running the ga with speciation (sharing using phenotype-wise)...\n";  cout.flush();  GASharing pheneSharing(PhenotypeDistance);  ga.scaling(pheneSharing);  ga.evolve();  genome = ga.statistics().bestIndividual();  cout << "the ga found an optimum at the point "<<genome.phenotype(0)<<endl;  outfile.open(popfilename3, (ios::out | ios::trunc));  if(outfile.fail()){    cerr << "Cannot open " << popfilename3 << " for output.\n";    exit(1);  }  for(i=0; i<ga.population().size(); i++){    outfile<<((GABin2DecGenome&)(ga.population().individual(i))).phenotype(0);    outfile << "\t";    outfile << ga.population().individual(i).score() << "\n";  }  outfile.close();// Now dump the function to file for comparisons  cout << "dumping the function to file..." << endl;  outfile.open(filename, (ios::out | ios::trunc));  if(outfile.fail()){    cerr << "Cannot open " << filename << " for output.\n";    exit(1);  }  float inc = MAX_VALUE - MIN_VALUE;  inc /= pow(2.0,NBITS);  for(float x=MIN_VALUE; x<=MAX_VALUE; x+=inc){    outfile << x << "\t" << FUNCTION (x) << "\n";  }  outfile << "\n";  outfile.close();  return 0;} // You can choose between one of two sinusoidal functions.  The first one has// peaks of equal amplitude.  The second is modulated.floatObjective(GAGenome & c){  GABin2DecGenome & genome = (GABin2DecGenome &)c;  return FUNCTION (genome.phenotype(0));}floatFunction1(float v) {  return 1 + sin(v*2*M_PI);}floatFunction2(float v) {  float y;  y = 100.0 * exp(-fabs(v) / 50.0) * (1.0 - cos(v * M_PI * 2.0 / 25.0));  if(v < -100 || v > 100) y = 0;  if(y < 0) y = 0;  return y+0.00001;}// Here are a couple of possible distance functions for this problem.  One of// them uses the genes to determine the same-ness, the other uses the// phenotypes to determine same-ness.  If the genomes are the same, then// we return a 0.  If they are completely different then we return a 1.//   In either case, you should be sure that the distance function will return// values only between 0 and 1 inclusive.  If your function returns values// outside these limits, the GA will produce bogus results and it WILL NOT warn// you that your distance function is brain-dead!// This distance function uses the genes to determine same-ness.  All we do // is check to see if the bit strings are identical.floatBitDistance(const GAGenome & c1, const GAGenome & c2){  GABin2DecGenome & a = (GABin2DecGenome &)c1;  GABin2DecGenome & b = (GABin2DecGenome &)c2;  float x=0;  for(int i=a.length()-1; i>=0; i--)    x += (a[i] != b[i] ? 1 : 0);  return x/a.length();}// This distance function looks at the phenotypes rather than the genes of the// genome.  This distance function will try to drive them to extremes.floatPhenotypeDistance(const GAGenome & c1, const GAGenome & c2){  GABin2DecGenome & a = (GABin2DecGenome &)c1;  GABin2DecGenome & b = (GABin2DecGenome &)c2;  return fabs(a.phenotype(0) - b.phenotype(0)) / (MAX_VALUE-MIN_VALUE);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人永久看片免费视频天堂| 一本久久a久久免费精品不卡| 天堂一区二区在线| 亚洲精品水蜜桃| 综合在线观看色| 亚洲视频精选在线| 亚洲欧洲另类国产综合| 中文字幕亚洲一区二区av在线| 日本一区二区三区四区| 国产欧美日韩精品在线| 国产色一区二区| 国产精品卡一卡二卡三| 中文字幕一区在线观看视频| 亚洲欧美精品午睡沙发| 亚洲图片有声小说| 日韩精品一二三| 看国产成人h片视频| 国产麻豆精品theporn| 国产精品18久久久久久久久久久久| 国产经典欧美精品| 99久久777色| 精品视频在线免费| 日韩欧美美女一区二区三区| 久久综合九色综合欧美98| 国产精品免费久久| 亚洲国产综合色| 美腿丝袜亚洲三区| 国产精品一区二区三区乱码| a级高清视频欧美日韩| 精品视频免费在线| 欧美精品一区二区三区在线播放| 国产亚洲福利社区一区| 亚洲男人都懂的| 午夜视频久久久久久| 另类欧美日韩国产在线| 国产精品一区二区x88av| 成人一区二区三区| 成人永久aaa| 欧美中文字幕一区二区三区| 91精品在线免费观看| 欧美xxxx在线观看| 国产欧美日韩另类一区| 亚洲免费观看视频| 午夜精品久久久| 美国毛片一区二区| 国产成人8x视频一区二区| 成人高清视频在线观看| 91精品91久久久中77777| 欧美日韩国产综合一区二区三区| 欧美一级电影网站| 5月丁香婷婷综合| 日本一区二区免费在线观看视频| 亚洲欧美日韩精品久久久久| 亚洲高清免费视频| 九一久久久久久| 成人在线一区二区三区| 在线观看亚洲精品视频| 日韩午夜精品视频| 国产欧美一区二区三区鸳鸯浴| 国产精品国产a| 亚洲高清中文字幕| 激情深爱一区二区| 色综合久久久网| 日韩一区二区高清| 国产精品久久久久7777按摩| 婷婷综合五月天| 免费在线观看一区二区三区| 精品亚洲免费视频| 一本大道久久a久久精品综合| 日韩一区二区在线看片| 中文子幕无线码一区tr| 偷偷要91色婷婷| 成人高清在线视频| 欧美一级黄色大片| 亚洲欧美怡红院| 蜜桃传媒麻豆第一区在线观看| av在线一区二区| 日韩亚洲欧美在线| 亚洲欧美偷拍卡通变态| 夜夜精品视频一区二区| 国产高清在线观看免费不卡| 欧美日韩精品欧美日韩精品一综合| 日韩欧美一区二区免费| 亚洲主播在线播放| 成人午夜视频网站| 日韩三级视频在线观看| 亚洲午夜电影在线观看| 成人av在线一区二区三区| 日韩你懂的在线播放| 亚洲国产综合色| 99re热这里只有精品免费视频| 精品少妇一区二区三区在线播放 | 亚洲国产人成综合网站| 国产一区二区三区高清播放| 9191成人精品久久| 亚洲色图在线播放| 国产91精品一区二区麻豆网站 | 欧美一区欧美二区| 亚洲男女一区二区三区| 成人在线综合网| 久久影院午夜片一区| 蜜桃91丨九色丨蝌蚪91桃色| 欧美日免费三级在线| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 久久超碰97中文字幕| 欧美一级日韩一级| 亚洲主播在线播放| 成人动漫中文字幕| 久久综合色综合88| 狠狠色狠狠色综合系列| 欧美一区中文字幕| 亚洲午夜精品在线| 欧美天堂一区二区三区| 洋洋成人永久网站入口| 91老司机福利 在线| 一区在线观看免费| 成人av在线看| 国产精品乱码一区二三区小蝌蚪| 国产成人午夜精品影院观看视频 | 久久99精品国产.久久久久| 日韩午夜激情免费电影| 青椒成人免费视频| 欧美一级二级在线观看| 日日夜夜精品视频天天综合网| 欧美日韩高清在线| 天堂一区二区在线免费观看| 91麻豆精品国产91久久久| 婷婷开心激情综合| 欧美精品高清视频| 亚洲国产精品一区二区www| 欧美日韩国产免费一区二区| 性做久久久久久久免费看| 欧美三级日韩三级国产三级| 午夜电影一区二区三区| 欧美日韩一二三| 奇米精品一区二区三区四区 | 欧美日韩国产成人在线91| 首页综合国产亚洲丝袜| 日韩免费观看高清完整版在线观看| 日本视频免费一区| 日韩精品一区二区三区视频| 国产做a爰片久久毛片| 亚洲国产成人自拍| 91蜜桃在线免费视频| 午夜精品影院在线观看| 精品视频一区二区三区免费| 国产专区综合网| 国产精品色在线| 欧美在线一二三| 久久国内精品视频| 欧美激情一区不卡| 色呦呦一区二区三区| 日本不卡高清视频| 国产日韩精品一区| 色综合色综合色综合色综合色综合| 亚洲成人动漫av| 久久日韩粉嫩一区二区三区| 国产精品一区二区x88av| 欧美成人国产一区二区| 99久久精品免费看| 亚洲国产精品天堂| 久久人人爽爽爽人久久久| 91看片淫黄大片一级| 日产国产欧美视频一区精品| 久久久精品日韩欧美| 91福利社在线观看| 久久国产精品99久久久久久老狼| 国产精品情趣视频| 欧美日韩国产高清一区二区| 国产精品一区二区x88av| 一区二区三区日韩欧美精品| 日韩欧美一区在线观看| 国产精品一区二区你懂的| 亚洲欧美日韩中文字幕一区二区三区 | 韩国三级中文字幕hd久久精品| 国产精品国产三级国产aⅴ中文 | 亚洲乱码国产乱码精品精98午夜| 99久久精品国产导航| 日韩精品乱码免费| 亚洲精品福利视频网站| 久久影音资源网| 欧美视频一区二区| 国产91在线观看| 日韩电影在线观看网站| 亚洲视频在线一区二区| 欧美成人女星排名| 欧美日韩亚洲综合在线| 99免费精品在线| 蜜桃久久久久久久| 亚洲国产日韩a在线播放性色| 国产日韩精品视频一区| 欧美一区二区三区播放老司机 | 欧美一区二区三区婷婷月色| jizz一区二区| 韩国三级在线一区| 亚洲综合一区在线| 成人欧美一区二区三区小说| 久久免费午夜影院| 91麻豆精品国产自产在线| 91丝袜美女网|