mut.h

来自「在c语言中实现的多目标优化」· C头文件 代码 · 共 37 行

H
37
字号
/* This is the module used to formulate the mutation routine*/void mutate(population *new_pop_ptr);             void mutate(population *new_pop_ptr){  int i,*ptr,j,r;  float rand1,*rand_float_ptr;  rand1=randomperc();  new_pop_ptr->ind_ptr = &(new_pop_ptr->ind[0]);    for(j = 0;j < popsize;j++)    {      ptr= &(new_pop_ptr->ind_ptr->genes[0]);      new_pop_ptr->ind_ptr =&(new_pop_ptr->ind[j+1]);                 /*Select bit */      for (i = 0;i < chrom;i++)	{	  rand1 = randomperc();	  	  /*Check whether to do mutation or not*/	  if(rand1 <= pmut_b)	    {	      if(*ptr == 0)		*ptr =1;	      else		*ptr=0;	      nmut++;	    }	  ptr++;	}    }  return;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?