标签:大于等于 for 拷贝 eal rank math.h 复制 return row
1 /* Routine for mergeing two populations */ 2 3 # include <stdio.h> 4 # include <stdlib.h> 5 # include <math.h> 6 7 # include "global.h" 8 # include "rand.h" 9 10 /* Routine to merge two populations into one */ 11 void merge(population *pop1, population *pop2, population *pop3) 12 { 13 int i, k; 14 for (i=0; i<popsize; i++) 15 { 16 copy_ind (&(pop1->ind[i]), &(pop3->ind[i])); 17 } 18 for (i=0, k=popsize; i<popsize; i++, k++) 19 { 20 copy_ind (&(pop2->ind[i]), &(pop3->ind[k])); 21 } 22 return; 23 } 24 25 /* Routine to copy an individual ‘ind1‘ into another individual ‘ind2‘ */ 26 void copy_ind (individual *ind1, individual *ind2) 27 { 28 int i, j; 29 ind2->rank = ind1->rank; 30 ind2->constr_violation = ind1->constr_violation; 31 ind2->crowd_dist = ind1->crowd_dist; 32 if (nreal!=0) 33 { 34 for (i=0; i<nreal; i++) 35 { 36 ind2->xreal[i] = ind1->xreal[i]; 37 } 38 } 39 if (nbin!=0) 40 { 41 for (i=0; i<nbin; i++) 42 { 43 ind2->xbin[i] = ind1->xbin[i]; 44 for (j=0; j<nbits[i]; j++) 45 { 46 ind2->gene[i][j] = ind1->gene[i][j]; 47 } 48 } 49 } 50 for (i=0; i<nobj; i++) 51 { 52 ind2->obj[i] = ind1->obj[i]; 53 } 54 if (ncon!=0) 55 { 56 for (i=0; i<ncon; i++) 57 { 58 ind2->constr[i] = ind1->constr[i]; 59 } 60 } 61 return; 62 }
copy_ind 具体进行两个个体 内容拷贝的函数。
29 ind2->rank = ind1->rank; 30 ind2->constr_violation = ind1->constr_violation; 31 ind2->crowd_dist = ind1->crowd_dist;
复制个体的 支配层 排序值。
复制个体的 限制条件 的超出值, 大于等于0未超出, 小于0为超出限制。
复制个体的 拥挤距离 。
判断个体的编码, 把个体的具体编码值 复制。
复制个体的 各个 目标函数的数值。
复制个体的 各个限制条件的 数值, 所有限制条件的数值之和等于 constr_violation 。
多目标遗传算法 ------ NSGA-II (部分源码解析)父、子种群合并 merge.c
标签:大于等于 for 拷贝 eal rank math.h 复制 return row
原文地址:http://www.cnblogs.com/devilmaycry812839668/p/6262115.html