filename changes
[unres.git] / source / ga / GA.f
index 3446217..be7bbda 100644 (file)
@@ -102,7 +102,7 @@ c Yes. Generate random zero-population
         do_ga=.false.
        endif 
 
-c End of "fisrst time here?" code
+c End of "first time here?" code
       endif
 
 c
@@ -168,6 +168,9 @@ c --- debug end ---
          write(tmptext,'(F7.5)') avrd
          call write2log("Average distance between individuals in initial&
      & bank is "//trim(tmptext))
+c
+c Cutoff 
+c
          csacutoff=(maxco*avrd)-generation*avrd*(maxco-minco)/maxgen
          write(tmptext,'(F7.5)') csacutoff
          call write2log("CSA cutoff is now set to "//trim(tmptext))
@@ -213,31 +216,37 @@ c --- debug end ---
            if (populacja(i,20).lt.bank(j,20)) then
             write(tmptext,'(I4)') j
             write(tmptext2,'(I4)') i
-            call write2log("Swaping ind"//trim(tmptext)//" from bank to &
-     &ind "//trim(tmptext2)//" from population")
-            write(tmptext2,'(21F7.5)') bank(j,:)
-            call write2log("BANK"//trim(tmptext)//":"//trim(tmptext2))
+            call write2log("  Swaping ind"//trim(tmptext)//" from bank t&
+     &o ind "//trim(tmptext2)//" from population")
+            write(tmptext2,'(19F8.5,E15.7,F8.5)') bank(j,:)
+            call write2log("  BANK"//trim(tmptext)//":"//trim(tmptext2))
 
             write(tmptext,'(I4)') i
-            write(tmptext2,'(21F7.5)') populacja(i,:)
-            call write2log("POP"//trim(tmptext)//":"//trim(tmptext2))
+            write(tmptext2,'(19F8.5,E15.7,F8.5)') populacja(i,:)
+            call write2log("  POP "//trim(tmptext)//":"//trim(tmptext2))
       
             bank(j,:)=populacja(i,:)
+           else
+            call write2log("  Found simialar but not better")
            endif
           else              ! W banku nie ma podobnego 
            j=FindWorst(banksize,bank)
-           write(tmptext,'(I4)') j
+           write(tmptext2,'(I4)') j
            if (populacja(i,20).lt.bank(j,20)) then
-            call write2log("Worst in bank is "//trim(tmptext))
-            write(tmptext2,'(21F7.5)') bank(j,:)
-            call write2log("BANK"//trim(tmptext)//":"//trim(tmptext2))
-           
+            call write2log("  Worst in bank is "//trim(tmptext2))
+            write(tmptext,'(I4)') i
+            call write2log("  Swaping worst ind in bank to "//trim(tmpte&
+     &xt))
+            write(tmptext,'(I4)') j
+            write(tmptext2,'(19F8.5,E15.7,F8.5)') bank(j,:)
+            call write2log("  BANK"//trim(tmptext)//":"//trim(tmptext2))
             write(tmptext,'(I4)') i
-            call write2log("Swaping worst ind in bank to "//trim(tmptext&
-     &))
-            write(tmptext2,'(21F7.5)') populacja(i,:)
-            call write2log("POP"//trim(tmptext)//":"//trim(tmptext2))
+            write(tmptext2,'(19F8.5,E15.7,F8.5)') populacja(i,:)
+            call write2log("  POP "//trim(tmptext)//":"//trim(tmptext2))
             bank(j,:)=populacja(i,:)
+           else
+            call write2log("  The worst in bank is better then this Ind"&
+     &)
            endif
           endif
          enddo
@@ -261,7 +270,7 @@ c --- debug end ---
 
         endif
        case('cluster')
-        write(*,*) "Some stuff here in the future"
+        write(*,*) "Well this is not implemented yet"
         goto 2010
       end select
 
@@ -1316,7 +1325,7 @@ c        call write2log("Delta is "//tmp)
           mindelta=delta
           pozycja=i
           write(tmp,'(F7.5,X,I4)') delta,pozycja
-          call write2log("Delta is "//tmp)
+          call write2log("  Delta is "//tmp)
         endif
       end do
 
@@ -1633,6 +1642,37 @@ c ----------------------------------------------------------------------
       end subroutine
 
 c ======================================================================
+c  WriteBankHistory subroutine
+c ======================================================================
+c  Writes CSA BANK History to file 
+c ----------------------------------------------------------------------
+      subroutine WriteBankHistory(b)
+       include 'io.inc'
+       include 'common.inc'
+       real*8,dimension(banksize,21) :: b  
+       character*250 :: tmptext
+       character*250 :: header   
+
+
+       header="#    WLONG      WSCP     WELEC     WBOND      WANG    WSC&
+     &LOC      WTOR     WTORD    WCORRH    WCORR4    WCORR5    WCORR6   &
+     &WEL_LOC    WTURN3    WTURN4    WTURN6    WVDWPP      WHPB    WSCCO&
+     &R            FFV   FITNESS" 
+       call write2log("Writing Bank history to file "//obankhfn)
+       open(obankh, file = obankhfn)
+       write(iobank, "(A)") trim(adjustl(header))
+       
+       do i=1,banksize
+        write(obankh,'(19F10.5,E15.7,F10.5)') (b(i,j),j=1,21)
+        write(tmptext,'(19F10.5,E15.7,F10.5)') (b(i,j),j=1,21)
+        call write2log(trim(tmptext))  
+       enddo 
+       close(iobank)
+      end subroutine
+
+c
+c ======================================================================
 c  ReadBank subroutine
 c ======================================================================
 c  Read CSA BANK from file