Replaces old population by new; recomputes fitnesses & ranks
ielite/=1
.Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pikaia_class), | intent(inout) | :: | me | |||
real(kind=wp), | intent(inout), | dimension(me%n,me%np) | :: | oldph | ||
real(kind=wp), | intent(inout), | dimension(me%n,me%np) | :: | newph | ||
integer, | intent(out), | dimension(me%np) | :: | ifit | ||
integer, | intent(out), | dimension(me%np) | :: | jfit | ||
real(kind=wp), | intent(out), | dimension(me%np) | :: | fitns | ||
integer, | intent(out) | :: | nnew |
subroutine newpop(me,oldph,newph,ifit,jfit,fitns,nnew) implicit none class(pikaia_class),intent(inout) :: me real(wp),dimension(me%n,me%np),intent(inout) :: oldph real(wp),dimension(me%n,me%np),intent(inout) :: newph integer,dimension(me%np),intent(out) :: ifit integer,dimension(me%np),intent(out) :: jfit real(wp),dimension(me%np),intent(out) :: fitns integer,intent(out) :: nnew integer :: i real(wp) :: f nnew = me%np if (me%ielite==1) then !if using elitism, introduce in new population fittest of old !population (if greater than fitness of the individual it is !to replace) call me%ff(newph(:,1),f) if (f<fitns(ifit(me%np))) then newph(:,1)=oldph(:,ifit(me%np)) nnew = nnew-1 end if end if !replace population oldph = newph !get fitness using caller's fitness function !$omp parallel do private(i) do i=1,me%np call me%ff(oldph(:,i),fitns(i)) end do !$omp end parallel do !compute new population fitness rank order call me%rnkpop(fitns,ifit,jfit) end subroutine newpop