V3FIT
ga_micro.f
1  SUBROUTINE ga_micro(i,npossum,ig2sum, myid)
2 c#######################################################################
3 c
4 c Micro-GA implementation SUBROUTINE
5 c
6  USE ga_mod
7  USE mpi_params, ONLY: master
8  IMPLICIT NONE
9  INTEGER :: i, npossum, ig2sum, myid
10  INTEGER :: icount, j, n
11  REAL(rprec) :: diffrac, rand
12  SAVE
13 c
14 c
15 c First, check for convergence of micro population.
16 c If converged, start a new generation with best individual and fill
17 c the remainder of the population with new randomly generated parents.
18 c
19 c Count number of different bits from best member in micro-population
20  icount=0
21  DO 81 j=1,npopsiz
22  DO 82 n=1,nchrome
23  IF(iparent(n,j).ne.ibest(n)) icount=icount+1
24  82 CONTINUE
25  81 CONTINUE
26 c
27 c If icount less than 5% of number of bits, THEN consider population
28 c to be converged. Restart with best individual and random others.
29  diffrac=real(icount,rprec)/((npopsiz-1)*nchrome)
30  IF (diffrac.lt.0.05_dp) THEN
31  DO 87 n=1,nchrome
32  iparent(n,1)=ibest(n)
33  87 CONTINUE
34  DO 88 j=2,npopsiz
35  DO 89 n=1,nchrome
36  CALL ran3(1,rand)
37  iparent(n,j)=1
38  IF(rand.lt.0.5_dp) iparent(n,j)=0
39  89 CONTINUE
40  88 CONTINUE
41  IF (npossum.lt.ig2sum) CALL ga_possibl(parent,iparent,myid)
42  IF (myid .eq. master) THEN
43  WRITE(6,1375) i
44  WRITE(iunit_ga_out,1375) i
45  END IF
46  END IF
47 
48  1375 FORMAT(//'%%%%%%% Restart micro-population at generation',
49  + i5,' %%%%%%%')
50 c
51  END SUBROUTINE ga_micro