遗传算法锦标赛选择java实现_多目标遗传算法 ------ NSGA-II (部分源码解析)二元锦标赛选择 tourselect.c...

本文详细介绍了NSGA-II多目标遗传算法中二元锦标赛选择的操作过程,通过C语言实现。代码展示了如何进行种群个体的随机选择、交叉操作,并解释了每个步骤的作用。通过对个体的支配关系、拥挤距离的判断,实现了公平的锦标赛选择,以生成新的种群。
摘要由CSDN通过智能技术生成

tourselect.c  文件中共有两个函数:

selection (population *old_pop, population *new_pop)

individual* tournament (individual *ind1, individual *ind2)

首先,第一个函数代码如下:

1 /*Routine for tournament selection, it creates a new_pop from old_pop by performing tournament selection and the crossover*/

2 void selection (population *old_pop, population *new_pop)3 {4 int *a1, *a2;5 inttemp;6 inti;7 intrand;8 individual *parent1, *parent2;9 a1 = (int *)malloc(popsize*sizeof(int));10 a2 = (int *)malloc(popsize*sizeof(int));11 for (i=0; iind[a1[i]], &old_pop->ind[a1[i+1]]);29 parent2 = tournament (&old_pop->ind[a1[i+2]], &old_pop->ind[a1[i+3]]);30 crossover (parent1, parent2, &new_pop->ind[i], &new_pop->ind[i+1]);31 parent1 = tournament (&old_pop->ind[a2[i]], &old_pop->ind[a2[i+1]]);32 parent2 = tournament (&old_pop->

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值