?? init.h
字號:
/*This is the file which initializes the population*/void init(population *pop_ptr);void init(population *pop_ptr){ int i,j,r; float d; pop_ptr->ind_ptr = &(pop_ptr->ind[0]); /*Loop Over the population size*/ for (i = 0 ; i < popsize ; i++) { /*Loop over the chromosome length*/ for (j = 0;j < chrom;j++) { /*Generate a Random No. if it is less than 0.5 it generates a 0 in the string otherwise 1*/ d = randomperc(); if(d >= 0.5) { pop_ptr->ind_ptr->genes[j] = 1; } else { pop_ptr->ind_ptr->genes[j] = 0; } } pop_ptr->ind_ptr = &(pop_ptr->ind[i+1]); } pop_ptr->ind_ptr = &(pop_ptr->ind[0]); return;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -