查看: 13107|回复: 1

[转载] 遗传算法的发展历史

[复制链接]
论坛徽章:
374
紫钻
日期:2011-12-27 21:35:04红钻
日期:2012-01-15 14:36:46迈阿密热火
日期:2018-06-13 16:31:54奥兰多魔术
日期:2018-06-13 16:31:54亚特兰大老鹰
日期:2018-06-13 16:31:54华盛顿奇才
日期:2018-06-13 16:31:54夏洛特黄蜂
日期:2018-06-13 16:31:54
跳转到指定楼层
1#
发表于 2009-8-16 14:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1、背景

    19的世纪世界四大学说之一是达尔文的自然选择学说。其主要内容有四点:过度繁殖,生存斗争(也叫生存竞争),遗传和变异,适者生存。

达尔文认为一切生物都具有产生变异的特性。引起变异的根本原因是环境条件的改变。在生物产生的各种变异中,有的可以遗传,有的不能够遗传。

在生存斗争中,具有有利变异的个体,容易在生存斗争中获胜而生存下去。反之,具有不利变异的个体,则容易在生存斗争中失败而死亡。这就是说,凡是生存下来的生物都是适应环境的,而被淘汰的生物都是对环境不适应的,这就是适者生存。达尔文把在生存斗争中,适者生存、不适者被淘汰的过程叫做自然选择。自然选择过程是一个长期的、缓慢的、连续的过程。由于生存斗争不断地进行,因而自然选择也是不断地进行,通过一代代的生存环境的选择作用,物种变异被定向地向着一个方向积累,于是性状逐渐和原来的祖先不同了,可以说物种也因此得到优化了。

2、起源与发展

遗传算法就是根据自然界这个“物竞天择,适者生存”现象而提出来的一种随机搜索算法。遗传算法起源于对生物系统所进行的计算机模拟研究。早在本世纪40 年代.就有学者开始研究如何利用计算机进行生物模拟的技术,他们从生物学的角度进行了生物的进化过程模拟、遴传过程棋拟等研究工作。进入60 年代后,美国密执安大学的Holland 教授及其学生们受到这种生物模拟技术的启发.创造出了一种基于生物遗传和进化机制的适合子复杂系统优化计算的自适应概率优化技术一遗传算法。

1967年,Holland的学生J.D.Bagley在博士论文中首次提出“遗传算法(Genetic Algorithms)”一词。此后,Holland指导学生完成了多篇有关遗传算法研究的论文。1971年,R.B.Hollstien在他的博士论文中首次把遗传算法用于函数优化。1975年是遗传算法研究历史上十分重要的一年。这一年Holland出版了他的著名专著《自然系统和人工系统的自适应》(Adaptation in Natural and Artificial Systems),这是第一本系统论述遗传算法的专著,因此有人把1975年作为遗传算法的诞生年。Holland在该书中系统地阐述了遗传算法的基本理论和方法,并提出了对遗传算法的理论研究和发展极其重要的模式理论(schema theory)。该理论首次确认了结构重组遗传操作对于获得隐并行性的重要性。同年,K.A.De Jong完成了他的博士论文《一类遗传自适应系统的行为分析》。该论文所做的研究工作,可看作是遗传算法发展进程中的一个里程碑,这是因为,他把Holland的模式理论与他的计算实验结合起来。尽管De Jong和Hollstien 一样主要侧重于函数优化的应用研究,但他将选择、交叉和变异操作进一步完善和系统化,同时又提出了诸如代沟(generation gap)等新的遗传操作技术。可以认为,De Jong的研究工作为遗传算法及其应用打下了坚实的基础,他所得出的许多结论,迄今仍具有普遍的指导意义。
    进入八十年代,遗传算法迎来了兴盛发展时期,无论是理论研究还是应用研究都成了十分热门的课题。1985年,在美国召开了第一届遗传算法国际会议(International Conference on Genetic Algorithms ,ICGA),并且成立国际遗传算法学会(International Society of Genetic Algorithms ,ISGA),以后每两年举行一次。1989年,Holland的学生D.E.Goldberg出版了专著 《搜索、优化和机器学习中的遗传算法》。该书总结了遗传算法研究的主要成果,对遗传算法及其应用作了全面而系统的论述。同年,美国斯坦福大学的Koza基于自然选择原则创造性地提出了用层次化的计算机程序来表达问题的遗传程序设计( genetic programming,   GP)方法,成功地解决了许多问题。 在欧洲,从1990年开始每隔一年举办一次Parallel Problem Solving from Nature 学术会议,其中遗传算法是会议主要内容之一。此外,以遗传算法的理论基础为中心的学术会议还有Foundations of Genetic Algorithms,该会也是从1990年开始隔年召开一次。这些国际会议论文,集中反映了遗传算法近些年来的最新发展和动向。 1991年,L.Davis编辑出版了《遗传算法手册》(Handbook of Genetic Algorithms),其中包括了遗传算法在工程技术和社会生活中的大量应用实例。
1992年,Koza发表了他的专著《遗传程序设计:基于自然选择法则的计算机程序设计》”。1994年,他又出版了《遗传程序设计,第二册:可重用程序的自动发现》深化了遗传程序设计的研究,使程序设计自动化展现了新局面。有关遗传算法的学术论文也不断在《Artificial Intelligence》、《Machine Learning》、《Information science》、《Parallel Computing》、《Genetic Programming and Evoluable Machine》《IEEE Transactions on Signal Processing》《IEEE Transactions on Neural Networks》等杂志上发表。1993年,MIT出版社创刊了新杂志《Evolutionary Computation》。1997年,IEEE又创刊了《Transactions on Evolutionary Computation》《Advanced Computational Intelligence》杂志即将发刊,由模糊集合创始人L.A.Zadeh教授为名誉主编。目前,关于遗传算法研究的热潮仍在持续,越来越多的从事不同领域的研究人员已经或正在置身于有关遗传算法的研究或应用之中。

3、  遗传算法领域的重要人物

1 ) J . H · Holland

60 年代,HoLland 认识到厂生物的遗传和自然进化现象与人工自适应系统的相似关系,运用生物遗传和进化的思想来研究自然和人工自适应系统的生成以及它们与环境的关系.提出在研究和设计人工自适应系统时,可以借鉴生物遗传的机制.以群体的方法进行自适应搜索,并且充分认识到了交叉、变异等运算策略在自适应系统中的重要性,
    70 年代初,Holland 教授提出了遗传算法的基本定理― 模式定理,从而莫定了遗传算法的理论基础,模式定理揭示出了群体中的优良个体(较好的模式)的样本数将以指数级规律增长,因而从理论上保证了遗传势法是一个可以用来寻求最优可行解的优化过程。1975 年,Holland 出版了第一本系统论述遗传算法和人工自适应系统的专著(自然系统和人工系统的自适应性(Adaption in Natural Artificial Systems)。80 年代,Holland 教授实现了第一个基于遗传算法的机器学习系统——分类器系统(Classifier Systems,简称CS ) 。开创了基于遗传算法的机器学习的新概念,为分类器系统构造出了一个完整的框架。
2 ) J . D . Bogley
1967年,Holland的学生Bogley 在其博士论文中首次提出了“遗传算法”这个词,并发表了遗传算法应用方面的第一篇论文。他发展了复制、交叉、变异、显性、倒位等遗传算子.在个体编码上使用了双倍体的编码方法。这些都与目前遗传统法中所使用的井子和方法相类似。他还敏锐地意识到了在遗传算法执行的不同阶段可以使用不同的选择率,这将有利于防止遗传算法的早热现象,从而创立了自适应遗传算法的概念。
3 ) K . A .De Jon g
1975 年,De Jong在其博士论文中结合模式定理进行了大量的纯数值函数优化计算实验,树立厂遗传算法的工作框架,得到了一些重要且具有指导意义的结论。例如,对于规模在50 一100 的群体,经过10 一20 代的进化,遗传算法都能以很高的概率找列最优或近似最优解。他准荐了在大多数优化问题中都较适用的遗传算法的参数,还建立了著名的De Jong 五函数测试平台,定义了评价遗传算法性能的在线指标和离线指标。

4 ) D .J . Goldberg
1989 年,Goldberg出版了专著“搜索、优化和机器学习中的遗传算法(Genetic Algorithms in Search,Oprimization and Machine Learning)。该书系统总结了遗传算法的主要研究成果,全面而完整地论述了边传算法的基本原理及其应用:可以说这本书莫定了现代遗传算法的科学基础.为众多研究和发展遗传算法的学者所瞩目。
5 ) I.Davis
1991 年.Davis,编揖出版了(遗传算法手册(Handbook of Genetic Algorithms)一书,书中包括了遗传算法在科学计算、工程技术和社会经济中的大公应用实例阁。这本书为推广和普及遗传算法的应用起到了重要的指导作用。

6 )J . R .Koza
1992 年.Koza将遗传算法应用于计算机程序的优化设计及自动生成,提出了 遗传编程(Genetic Programming ,简称GP ) 的概念。他将一段LlSP 语言程序作为个体的基因型.把问题的解编码为一裸树,基于遗传和进化的概念,对由树组成的群体进行遗传运算,最终自动生成性能较好的计算机程序。Koza 成功地把他提出的遗传编程的方法应用工人工智能、机器学习、符号处理等方面。
论坛徽章:
374
紫钻
日期:2011-12-27 21:35:04红钻
日期:2012-01-15 14:36:46迈阿密热火
日期:2018-06-13 16:31:54奥兰多魔术
日期:2018-06-13 16:31:54亚特兰大老鹰
日期:2018-06-13 16:31:54华盛顿奇才
日期:2018-06-13 16:31:54夏洛特黄蜂
日期:2018-06-13 16:31:54
2#
 楼主| 发表于 2009-8-16 14:23 | 只看该作者
参考code
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

/* Change any of these parameters to match your needs */

#define POPSIZE 50               /* population size */
#define MAXGENS 1000             /* max. number of generations */
#define NVARS 3                  /* no. of problem variables */
#define PXOVER 0.8               /* probability of crossover */
#define PMUTATION 0.15           /* probability of mutation */
#define TRUE 1
#define FALSE 0

int generation;                  /* current generation no. */
int cur_best;                    /* best individual */
FILE *galog;                     /* an output file */

struct genotype /* genotype (GT), a member of the population */
{
  double gene[NVARS];        /* a string of variables */
  double fitness;            /* GT's fitness */
  double upper[NVARS];       /* GT's variables upper bound */
  double lower[NVARS];       /* GT's variables lower bound */
  double rfitness;           /* relative fitness */
  double cfitness;           /* cumulative fitness */
};

struct genotype population[POPSIZE+1];    /* population */
struct genotype newpopulation[POPSIZE+1]; /* new population; */
                                          /* replaces the */
                                          /* old generation */

/* Declaration of procedures used by this genetic algorithm */

void initialize(void);
double randval(double, double);
void evaluate(void);
void keep_the_best(void);
void elitist(void);
void select(void);
void crossover(void);
void Xover(int,int);
void swap(double *, double *);
void mutate(void);
void report(void);

/***************************************************************/
/* Initialization function: Initializes the values of genes    */
/* within the variables bounds. It also initializes (to zero)  */
/* all fitness values for each member of the population. It    */
/* reads upper and lower bounds of each variable from the      */
/* input file `gadata.txt'. It randomly generates values       */
/* between these bounds for each gene of each genotype in the  */
/* population. The format of the input file `gadata.txt' is    */
/* var1_lower_bound var1_upper bound                           */
/* var2_lower_bound var2_upper bound ...                       */
/***************************************************************/

void initialize(void)
{
FILE *infile;
int i, j;
double lbound, ubound;

if ((infile = fopen("gadata.txt","r"))==NULL)
      {
      fprintf(galog,"\nCannot open input file!\n");
      exit(1);
      }

/* initialize variables within the bounds */

for (i = 0; i < NVARS; i++)
      {
      fscanf(infile, "%lf",&lbound);
      fscanf(infile, "%lf",&ubound);

      for (j = 0; j < POPSIZE; j++)
           {
           population[j].fitness = 0;
           population[j].rfitness = 0;
           population[j].cfitness = 0;
           population[j].lower = lbound;
           population[j].upper= ubound;
           population[j].gene = randval(population[j].lower,
                                   population[j].upper);
           }
      }

fclose(infile);
}

/***********************************************************/
/* Random value generator: Generates a value within bounds */
/***********************************************************/

double randval(double low, double high)
{
double val;
val = ((double)(rand()%1000)/1000.0)*(high - low) + low;
return(val);
}

/*************************************************************/
/* Evaluation function: This takes a user defined function.  */
/* Each time this is changed, the code has to be recompiled. */
/* The current function is:  x[1]^2-x[1]*x[2]+x[3]           */
/*************************************************************/

void evaluate(void)
{
int mem;
int i;
double x[NVARS+1];

for (mem = 0; mem < POPSIZE; mem++)
      {
      for (i = 0; i < NVARS; i++)
            x[i+1] = population[mem].gene;
      
      population[mem].fitness = (x[1]*x[1]) - (x[1]*x[2]) + x[3];
      }
}

/***************************************************************/
/* Keep_the_best function: This function keeps track of the    */
/* best member of the population. Note that the last entry in  */
/* the array Population holds a copy of the best individual    */
/***************************************************************/

void keep_the_best()
{
int mem;
int i;
cur_best = 0; /* stores the index of the best individual */

for (mem = 0; mem < POPSIZE; mem++)
      {
      if (population[mem].fitness > population[POPSIZE].fitness)
            {
            cur_best = mem;
            population[POPSIZE].fitness = population[mem].fitness;
            }
      }
/* once the best member in the population is found, copy the genes */
for (i = 0; i < NVARS; i++)
      population[POPSIZE].gene = population[cur_best].gene;
}

/****************************************************************/
/* Elitist function: The best member of the previous generation */
/* is stored as the last in the array. If the best member of    */
/* the current generation is worse then the best member of the  */
/* previous generation, the latter one would replace the worst  */
/* member of the current population                             */
/****************************************************************/

void elitist()
{
int i;
double best, worst;             /* best and worst fitness values */
int best_mem, worst_mem; /* indexes of the best and worst member */

best = population[0].fitness;
worst = population[0].fitness;
for (i = 0; i < POPSIZE - 1; ++i)
      {
      if(population.fitness > population[i+1].fitness)
            {      
            if (population.fitness >= best)
                  {
                  best = population.fitness;
                  best_mem = i;
                  }
            if (population[i+1].fitness <= worst)
                  {
                  worst = population[i+1].fitness;
                  worst_mem = i + 1;
                  }
            }
      else
            {
            if (population.fitness <= worst)
                  {
                  worst = population.fitness;
                  worst_mem = i;
                  }
            if (population[i+1].fitness >= best)
                  {
                  best = population[i+1].fitness;
                  best_mem = i + 1;
                  }
            }
      }
/* if best individual from the new population is better than */
/* the best individual from the previous population, then    */
/* copy the best from the new population; else replace the   */
/* worst individual from the current population with the     */
/* best one from the previous generation                     */

if (best >= population[POPSIZE].fitness)
    {
    for (i = 0; i < NVARS; i++)
       population[POPSIZE].gene = population[best_mem].gene;
    population[POPSIZE].fitness = population[best_mem].fitness;
    }
else
    {
    for (i = 0; i < NVARS; i++)
       population[worst_mem].gene = population[POPSIZE].gene;
    population[worst_mem].fitness = population[POPSIZE].fitness;
    }
}
/**************************************************************/
/* Selection function: Standard proportional selection for    */
/* maximization problems incorporating elitist model - makes  */
/* sure that the best member survives                         */
/**************************************************************/

void select(void)
{
int mem, i, j, k;
double sum = 0;
double p;

/* find total fitness of the population */
for (mem = 0; mem < POPSIZE; mem++)
      {
      sum += population[mem].fitness;
      }

/* calculate relative fitness */
for (mem = 0; mem < POPSIZE; mem++)
      {
      population[mem].rfitness =  population[mem].fitness/sum;
      }
population[0].cfitness = population[0].rfitness;

/* calculate cumulative fitness */
for (mem = 1; mem < POPSIZE; mem++)
      {
      population[mem].cfitness =  population[mem-1].cfitness +      
                          population[mem].rfitness;
      }

/* finally select survivors using cumulative fitness. */

for (i = 0; i < POPSIZE; i++)
      {
      p = rand()%1000/1000.0;
      if (p < population[0].cfitness)
            newpopulation = population[0];      
      else
            {
            for (j = 0; j < POPSIZE;j++)      
                  if (p >= population[j].cfitness &&
                              p<population[j+1].cfitness)
                        newpopulation = population[j+1];
            }
      }
/* once a new population is created, copy it back */

for (i = 0; i < POPSIZE; i++)
      population = newpopulation;      
}

/***************************************************************/
/* Crossover selection: selects two parents that take part in  */
/* the crossover. Implements a single point crossover          */
/***************************************************************/

void crossover(void)
{
int i, mem, one;
int first  =  0; /* count of the number of members chosen */
double x;

for (mem = 0; mem < POPSIZE; ++mem)
      {
      x = rand()%1000/1000.0;
      if (x < PXOVER)
            {
            ++first;
            if (first % 2 == 0)
                  Xover(one, mem);
            else
                  one = mem;
            }
      }
}
/**************************************************************/
/* Crossover: performs crossover of the two selected parents. */
/**************************************************************/

void Xover(int one, int two)
{
int i;
int point; /* crossover point */

/* select crossover point */
if(NVARS > 1)
   {
   if(NVARS == 2)
         point = 1;
   else
         point = (rand() % (NVARS - 1)) + 1;

   for (i = 0; i < point; i++)
        swap(&population[one].gene, &population[two].gene);

   }
}

/*************************************************************/
/* Swap: A swap procedure that helps in swapping 2 variables */
/*************************************************************/

void swap(double *x, double *y)
{
double temp;

temp = *x;
*x = *y;
*y = temp;

}

/**************************************************************/
/* Mutation: Random uniform mutation. A variable selected for */
/* mutation is replaced by a random value between lower and   */
/* upper bounds of this variable                              */
/**************************************************************/

void mutate(void)
{
int i, j;
double lbound, hbound;
double x;

for (i = 0; i < POPSIZE; i++)
      for (j = 0; j < NVARS; j++)
            {
            x = rand()%1000/1000.0;
            if (x < PMUTATION)
                  {
                  /* find the bounds on the variable to be mutated */
                  lbound = population.lower[j];
                  hbound = population.upper[j];  
                  population.gene[j] = randval(lbound, hbound);
                  }
            }
}

/***************************************************************/
/* Report function: Reports progress of the simulation. Data   */
/* dumped into the  output file are separated by commas        */
/***************************************************************/

void report(void)
{
int i;
double best_val;            /* best population fitness */
double avg;                 /* avg population fitness */
double stddev;              /* std. deviation of population fitness */
double sum_square;          /* sum of square for std. calc */
double square_sum;          /* square of sum for std. calc */
double sum;                 /* total population fitness */

sum = 0.0;
sum_square = 0.0;

for (i = 0; i < POPSIZE; i++)
      {
      sum += population.fitness;
      sum_square += population.fitness * population.fitness;
      }

avg = sum/(double)POPSIZE;
square_sum = avg * avg * POPSIZE;
stddev = sqrt((sum_square - square_sum)/(POPSIZE - 1));
best_val = population[POPSIZE].fitness;

fprintf(galog, "\n%5d,      %6.3f, %6.3f, %6.3f \n\n", generation,
                                      best_val, avg, stddev);
}

/**************************************************************/
/* Main function: Each generation involves selecting the best */
/* members, performing crossover & mutation and then          */
/* evaluating the resulting population, until the terminating */
/* condition is satisfied                                     */
/**************************************************************/

void main(void)
{
int i;

if ((galog = fopen("galog.txt","w"))==NULL)
      {
      exit(1);
      }
generation = 0;

fprintf(galog, "\n generation  best  average  standard \n");
fprintf(galog, " number      value fitness  deviation \n");

initialize();
evaluate();
keep_the_best();
while(generation<MAXGENS)
      {
      generation++;
      select();
      crossover();
      mutate();
      report();
      evaluate();
      elitist();
      }
fprintf(galog,"\n\n Simulation completed\n");
fprintf(galog,"\n Best member: \n");

for (i = 0; i < NVARS; i++)
   {
   fprintf (galog,"\n var(%d) = %3.3f",i,population[POPSIZE].gene);
   }
fprintf(galog,"\n\n Best fitness = %3.3f",population[POPSIZE].fitness);
fclose(galog);
printf("Success\n");
}

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表