newpop Subroutine

private subroutine newpop(me, oldph, newph, ifit, jfit, fitns, nnew)

Replaces old population by new; recomputes fitnesses & ranks

History

  • Jacob Williams : 3/9/2015 : avoid unnecessary function evaluation if ielite/=1.

Type Bound

pikaia_class

Arguments

Type IntentOptional 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

Calls

proc~~newpop~~CallsGraph proc~newpop pikaia_module::pikaia_class%newpop proc~func_wrapper pikaia_module::pikaia_class%func_wrapper proc~newpop->proc~func_wrapper proc~rnkpop pikaia_module::pikaia_class%rnkpop proc~newpop->proc~rnkpop proc~rqsort pikaia_module::rqsort proc~rnkpop->proc~rqsort

Called by

proc~~newpop~~CalledByGraph proc~newpop pikaia_module::pikaia_class%newpop proc~pikaia pikaia_module::pikaia_class%pikaia proc~pikaia->proc~newpop proc~solve_with_pikaia pikaia_module::pikaia_class%solve_with_pikaia proc~solve_with_pikaia->proc~pikaia

Source Code

    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