📄 realmut.h
字号:
/* This is the module used to formulate the mutation routine*/void real_mutate (individual * new_pop_ptr);voidreal_mutate (individual * new_pop_ptr){ int i, j, r; float rnd, delta, indi, *ptr, *ptr1, deltaq; float y, yl, yu, val, xy; for (i = 0; i < N_of_x; i++) { rnd = randomperc (); /*For each variable find whether to do mutation or not */ if (rnd <= p_mutation_real) { y = new_pop_ptr->xreal[i]; yl = infimumx[i]; yu = supremumx[i]; if (y > yl) { /*Calculate delta */ if ((y - yl) < (yu - y)) delta = (y - yl) / (yu - yl); else delta = (yu - y) / (yu - yl); rnd = randomperc (); indi = 1.0 / (n_distribution_m + 1.0); if (rnd <= 0.5) { xy = 1.0 - delta; val = 2 * rnd + (1 - 2 * rnd) * (pow (xy, (n_distribution_m + 1))); deltaq = pow (val, indi) - 1.0; } else { xy = 1.0 - delta; val = 2.0 * (1.0 - rnd) + 2.0 * (rnd - 0.5) * (pow (xy, (n_distribution_m + 1))); deltaq = 1.0 - (pow (val, indi)); } /*Change the value for the parent */ // *ptr = *ptr + deltaq*(yu-yl); // Added by Deb (31/10/01) y = y + deltaq * (yu - yl); if (y < yl) y = yl; if (y > yu) y = yu; new_pop_ptr->xreal[i] = y; } else // y == yl { xy = randomperc (); new_pop_ptr->xreal[i] = xy * (yu - yl) + yl; } } // ptr++; } return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -