V3FIT
ga_shuffle.f
1  SUBROUTINE ga_shuffle(ipick)
2 c#######################################################################
3 c
4 c This routine shuffles the parent array and its corresponding fitness
5 c
6  USE ga_mod
7  IMPLICIT NONE
8  INTEGER :: ipick, j, n, itemp, iother
9  REAL(rprec) :: rand, temp
10  SAVE
11 c
12  ipick=1
13  DO 10 j=1,npopsiz-1
14  CALL ran3(1,rand)
15  iother=j+1+int((npopsiz-j)*rand)
16  DO 20 n=1,nchrome
17  itemp=iparent(n,iother)
18  iparent(n,iother)=iparent(n,j)
19  iparent(n,j)=itemp
20  20 CONTINUE
21  temp=fitness(iother)
22  fitness(iother)=fitness(j)
23  fitness(j)=temp
24  10 CONTINUE
25 c
26  END SUBROUTINE ga_shuffle