V3FIT
ga_mutate.f
1  SUBROUTINE ga_mutate (myid)
2 c#######################################################################
3 c
4  USE ga_mod
5  USE mpi_params, ONLY: master
6  IMPLICIT NONE
7  INTEGER :: nmutate, ncreep, j, k, myid
8  REAL(rprec) :: rand, creep
9  SAVE
10 c
11 c This SUBROUTINE performs mutations on the children generation.
12 c Perform random jump mutation IF a random number is less than pmutate.
13 c Perform random creep mutation IF a different random number is less
14 c than pcreep.
15  nmutate=0
16  ncreep=0
17  DO 70 j=1,npopsiz
18  DO 75 k=1,nchrome
19 c Jump mutation
20  CALL ran3(1,rand)
21  IF (rand.le.pmutate) THEN
22  nmutate=nmutate+1
23  IF(ichild(k,j).eq.0) THEN
24  ichild(k,j)=1
25  ELSE
26  ichild(k,j)=0
27  END IF
28  IF (nowrite.eq.0 .and. myid.eq.master) THEN
29  WRITE(6,1300) j,k
30  WRITE(iunit_ga_out,1300) j,k
31  END IF
32  END IF
33  75 CONTINUE
34 c Creep mutation (one discrete position away).
35  IF (icreep.ne.0) THEN
36  DO 76 k=1,nparam
37  CALL ran3(1,rand)
38  IF(rand.le.pcreep) THEN
39  CALL ga_decode(j,child,ichild)
40  ncreep=ncreep+1
41  creep=1
42  CALL ran3(1,rand)
43  IF (rand.lt.0.5_dp) creep=-1
44  child(k,j)=child(k,j)+g1(k)*creep
45  IF (child(k,j).gt.par_max(k)) THEN
46  child(k,j)=par_max(k)-1.0d0*g1(k)
47  ELSEIF (child(k,j).lt.par_min(k)) THEN
48  child(k,j)=par_min(k)+g1(k)
49  END IF
50  CALL ga_code(j,k,child,ichild)
51  IF (nowrite.eq.0 .and. myid.eq.master) THEN
52  WRITE(6,1350) j,k
53  WRITE(iunit_ga_out,1350) j,k
54  END IF
55  END IF
56  76 CONTINUE
57  END IF
58  70 CONTINUE
59  IF (myid .eq. master) THEN
60  WRITE(6,1250) nmutate,ncreep
61  WRITE(iunit_ga_out,1250) nmutate,ncreep
62  END IF
63 
64  1250 FORMAT(/' Number of Jump Mutations =',i5/
65  + ' Number of Creep Mutations =',i5)
66  1300 FORMAT('*** Jump mutation performed on individual ',i4,
67  + ', chromosome ',i3,' ***')
68  1350 FORMAT('*** Creep mutation performed on individual ',i4,
69  + ', PARAMETER ',i3,' ***')
70 c
71  END SUBROUTINE ga_mutate