标签:ESS turn position let nbsp pre spi 比例 ble
轮盘赌选择,(也称为适应度比例选择)使用轮盘赌为类比,从种群中选择个体的方法。这种想法是根据个体在种群中的个体适应度值,将他们放置在一个假想的空间轮盘上。个体的适应度越高,在轮盘上占据的空间就越多,就越容易被选上;
简单实现代码如下:
Individual individuals[]=population.getIndividuals(); double populationFitness=population.getPopulationFitness(); double rouletteWheelPosition=Math.random()*populationFitness; double spinWheel=0; for(Individual individual:individuals) { spinWheel+=individual.getFitness(); if(spinWheel>=rouletteWheelPosition) { return individual; } } return individuals[population.size()-1];
标签:ESS turn position let nbsp pre spi 比例 ble
原文地址:https://www.cnblogs.com/mayeye/p/9623476.html