X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=blobdiff_plain;f=source%2Fga%2FGA.f;h=2304bfdfb097975ad5a4c19263084523c023b414;hb=e3de298b7f59bb5438206b21a80a578ee7c4f18f;hp=8d5b1aa4a6bca243dd6ebc419abf677ddde29ace;hpb=5292ed5bd4e5f8929fd456d3497b8695eb6d2c60;p=unres.git diff --git a/source/ga/GA.f b/source/ga/GA.f index 8d5b1aa..2304bfd 100644 --- a/source/ga/GA.f +++ b/source/ga/GA.f @@ -11,7 +11,7 @@ integer*4 :: mnoznik = 10 character*16 :: mode,argn,argi,dir_nam character*15 :: filename - real*8 :: loc,fc,sumfitness,sump,avrp,maxfc,avrd + real*8 :: loc,fc,sumfitness,sump,avrp,maxfc real :: rand, r real*8 :: maxfcever real*8 :: FunkcjaCeluB, FunkcjaCeluB2, FunkcjaCeluR @@ -31,7 +31,7 @@ c ======================================================================= call ReadInput(status) - if ((maxminstep.gt.0).and.(generation.eq.1)) then + if ((maxminstep.gt.0).and.(generation.eq.0)) then c Do first score do_fs=.true. endif @@ -78,7 +78,8 @@ c No. Prepere next generation open(ostate,file=ostatefn) read(ostate,'(I4)') generation read(ostate,'(L2)') do_optima - read(ostate,'(L2)') do_ga + read(ostate,'(L2)') do_ga + read(ostate,'(F7.5)') avrd close(ostate) if (do_ga) then call write2log("Doing GA in this step") @@ -88,12 +89,15 @@ c No. Prepere next generation call write2log("ZSCORE weights minimalization disabled for now") generation=generation+1 endif - + write(tmptext,'(I4)') generation + call write2log("This is genaration "//tmptext) call ReadOptimaW(BANK_MULTIPLIER*banksize,populacja) c Yes. Generate random zero-population else call GenPopulation(BANK_MULTIPLIER*banksize,populacja) + write(tmptext,'(I4)') generation + call write2log("This is genaration "//tmptext) if (do_optima) then do_ga=.false. endif @@ -142,17 +146,17 @@ c --- debug begin --- write(*,*) "do_ga: ",do_ga write(*,*) "do_optima: ",do_optima write(*,*) "do_fs: ",do_fs - write(*,*) "cicutoff: ", cicutoff +c write(*,*) "cicutoff: ", cicutoff endif c --- debug end --- - csacutoff=cicutoff +c csacutoff=cicutoff c c Fill the bank just after the first time we get the score c - if (((generation.eq.2).and.(maxminstep.eq.0)).or.((generation.eq& - &.2).and.(maxminstep.gt.0))) then + if (((generation.eq.1).and.(maxminstep.eq.0)).or.((generation.eq& + &.1).and.(maxminstep.gt.0))) then c --- debug begin --- if (debug) then @@ -160,6 +164,17 @@ c --- debug begin --- endif c --- debug end --- call GetNBest(populacja,bank,banksize) + call CalcAvgDist(bank,avrd) + write(tmptext,'(F7.5)') avrd + call write2log("Average distance between individuals in initial& + & bank is "//trim(tmptext)) + csacutoff=(maxco*avrd)-generation*avrd*(maxco-minco)/maxgen + write(tmptext,'(F7.5)') csacutoff + call write2log("CSA cutoff is now set to "//trim(tmptext)) +c csacutoff=maxco*avrd + + + c --- debug begin --- if (debug) then do i=1,banksize @@ -183,13 +198,16 @@ c --- debug begin --- c --- debug end --- call ReadBank(bank) - call CalcAvgDist(bank,avrd) write(tmptext,'(F7.5)') avrd call write2log("Average distance in bank is "//trim(tmptext)) + + csacutoff=maxco*avrd-generation*avrd*(maxco-minco)/maxgen + write(tmptext,'(F7.5)') csacutoff + call write2log("CSA cutoff is now set to "//trim(tmptext)) do i=1,BANK_MULTIPLIER*banksize write(tmptext,'(I4)') i - call write2log("Checking ind "//tmptext) + call write2log("Checking ind "//trim(tmptext)) j=ZnajdzPodobnego(banksize,bank,populacja(i,:),csacutoff) if (j.gt.0) then if (populacja(i,20).lt.bank(j,20)) then @@ -228,12 +246,7 @@ c --- debug begin --- c --- debug end --- call WriteBank(bank) - csacutoff=csacutoff-(generation*cicutoff/maxgen) -c csacutoff=cicutoff*(0.8**(iter-1)) - - write(tmptext,'(F7.5)') csacutoff - call write2log("CSA cutoff is now set to "//tmptext) endif case('cluster') write(*,*) "Some stuff here in the future" @@ -375,7 +388,7 @@ c else if (do_fs) then do_optima=.not.do_optima - if (generation.eq.1) then + if (generation.eq.0) then do_ga=.false. else do_ga=.not.do_ga @@ -395,9 +408,9 @@ c call WritePopSum() c c Create the inputs c - write(tmptext,'(I)') generation - call write2log("Preparing inputs for generation "//trim(adjustl(tm& - &ptext))) + write(tmptext,'(I)') generation+1 + call write2log("Preparing inputs for next generation ("//trim(adju& + &stl(tmptext))//")") call CreateInputs(BANK_MULTIPLIER*banksize,populacja) c c All done? Then let's quit. @@ -818,29 +831,31 @@ c ====================================================================== do read(inp, '(A)', iostat=stat) wiersz if (stat /= 0) exit - if ((wiersz(1:4).eq.'PDB=').or.(wiersz(1:4).eq.'pdb=')) then - npdb=1 - tmp = wiersz(5:len_trim(wiersz)) - do i=1,len_trim(tmp) - if (tmp(i:i).eq.' ') then - npdb=npdb+1 - endif - end do - if (npdb.gt.maxnpdb) then - call write2log("Number of input PDB exceeds maxnpdb!") - status = 1 - exit - endif - do i=1,npdb - if (index(trim(tmp),' ').gt.0) then - pdbfiles(i)=tmp(1:index(trim(tmp),' ')) - else - pdbfiles(i)=tmp(1:len_trim(tmp)) - endif - tmp=tmp(index(trim(tmp),' ')+1:len_trim(tmp)) +c PDB= + if ((wiersz(1:4).eq.'PDB=').or.(wiersz(1:4).eq.'pdb=')) then + npdb=1 + tmp = wiersz(5:len_trim(wiersz)) + do i=1,len_trim(tmp) + if (tmp(i:i).eq.' ') then + npdb=npdb+1 + endif + end do + if (npdb.gt.maxnpdb) then + call write2log("Number of input PDB exceeds maxnpdb!") + status = 1 + exit + endif + do i=1,npdb + if (index(trim(tmp),' ').gt.0) then + pdbfiles(i)=tmp(1:index(trim(tmp),' ')) + else + pdbfiles(i)=tmp(1:len_trim(tmp)) + endif + tmp=tmp(index(trim(tmp),' ')+1:len_trim(tmp)) end do endif ! Koniec czytania "PDB=" - + +c ALG= if ((wiersz(1:4).eq.'ALG=').or.(wiersz(1:4).eq.'alg=')) then alg=wiersz(5:len_trim(wiersz)) select case(alg) @@ -858,22 +873,40 @@ c ====================================================================== alg="csa" call write2log ("Unknown algorithm. Using 'csa' as default") end select - endif ! Koniec czytania "ALG=" + endif +c GENERATIONS= select case (wiersz(1:12)) case('GENERATIONS=','generations=') tmp = wiersz(13:len_trim(wiersz)) read(tmp,'(I)') maxgen - end select ! Koniec czytania "GENERATIONS=" + end select c CICUTOFF= - select case(wiersz(1:9)) - case('CICUTOFF=','cicutoff=') - tmp = wiersz(10:len_trim(wiersz)) - read(tmp(1:len_trim(tmp)),'(F7.5)') cicutoff - call write2log("Initial CSA cutoff is set to "//tmp) +c select case(wiersz(1:9)) +c case('CICUTOFF=','cicutoff=') +c tmp = wiersz(10:len_trim(wiersz)) +c read(tmp(1:len_trim(tmp)),'(F7.5)') cicutoff +c call write2log("Initial CSA cutoff is set to "//tmp) +c end select + +c MINCO= + select case(wiersz(1:6)) + case('MINCO=','minco=') + tmp = wiersz(7:len_trim(wiersz)) + read(tmp(1:len_trim(tmp)),'(F7.5)') minco + call write2log("Minimal CSA cutoff factor is set to "//tmp) + end select + +c MAXCO= + select case(wiersz(1:6)) + case('MAXCO=','maxco=') + tmp = wiersz(7:len_trim(wiersz)) + read(tmp(1:len_trim(tmp)),'(F7.5)') maxco + call write2log("Maximal CSA cutoff factor is set to "//tmp) end select + c POPULATION= select case(wiersz(1:11)) case('POPULATION=','population=') @@ -1338,6 +1371,7 @@ c ---------------------------------------------------------------------- write(ostate,'(I4)') generation write(ostate,'(L2)') do_optima write(ostate,'(L2)') do_ga + write(ostate,'(F7.5)') avrd close(ostate) end subroutine WriteState