📄 mut.h
字号:
/* 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -