Selects two parents from the population, using roulette wheel algorithm with the relative fitnesses of the phenotypes as the "hit" probabilities.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pikaia_class), | intent(inout) | :: | me | |||
integer, | intent(in), | dimension(me%np) | :: | jfit | ||
integer, | intent(out) | :: | imom | |||
integer, | intent(out) | :: | idad |
subroutine select_parents(me,jfit,imom,idad) implicit none class(pikaia_class),intent(inout) :: me integer,dimension(me%np),intent(in) :: jfit integer,intent(out) :: imom integer,intent(out) :: idad integer :: np1,i,j real(wp) :: dice,rtfit integer,dimension(2) :: parents !initialize: np1 = me%np+1 parents = -99 !get two (unequal) parents: do j=1,2 main: do dice = me%urand()*me%np*np1 rtfit = 0.0_wp do i=1,me%np rtfit = rtfit+np1+me%fdif*(np1-2*jfit(i)) if (rtfit>=dice) then parents(j) = i if (parents(1)/=parents(2)) exit main end if end do end do main end do imom = parents(1) idad = parents(2) end subroutine select_parents