⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mutation.c

📁 多目标遗传算法的程序
💻 C
字号:
/* Mutation routines */# include <stdio.h># include <stdlib.h># include <math.h># include "global.h"# include "rand.h"/* Function to perform mutation in a population */void mutation_pop (population *pop){    int i;    for (i=0; i<popsize; i++)    {        mutation_ind(&(pop->ind[i]));    }    return;}/* Function to perform mutation of an individual */void mutation_ind (individual *ind){    if (nreal!=0)    {        real_mutate_ind(ind);    }    return;}/* Routine for real polynomial mutation of an individual */void real_mutate_ind (individual *ind){    int j;    long double rnd, delta1, delta2, mut_pow, deltaq;    long double y, yl, yu, val, xy;    for (j=0; j<nreal; j++)    {        if (randomperc() <= pmut_real)        {            y = ind->xreal[j];            yl = min_realvar[j];            yu = max_realvar[j];            delta1 = (y-yl)/(yu-yl);            delta2 = (yu-y)/(yu-yl);            rnd = randomperc();            mut_pow = 1.0/(eta_m+1.0);            if (rnd <= 0.5)            {                xy = 1.0-delta1;                val = 2.0*rnd+(1.0-2.0*rnd)*(pow(xy,(eta_m+1.0)));                deltaq =  pow(val,mut_pow) - 1.0;            }            else            {                xy = 1.0-delta2;                val = 2.0*(1.0-rnd)+2.0*(rnd-0.5)*(pow(xy,(eta_m+1.0)));                deltaq = 1.0 - (pow(val,mut_pow));            }            y = y + deltaq*(yu-yl);            if (y<yl)                y = yl;            if (y>yu)                y = yu;            ind->xreal[j] = y;            nrealmut+=1;        }    }    return;}

⌨️ 快捷键说明

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