diff --git a/DESCRIPTION b/DESCRIPTION index 1a898304457ac3ed0179be68fbb53a0e940da4ff..cedea15572167edcbcc343bfeee1bf3e6d813f41 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: hydroPSO Type: Package Title: Model-Independent Particle Swarm Optimisation for Environmental Models -Version: 0.1-58-15 -Date: 2012-10-28 +Version: 0.1-58-16 +Date: 2012-10-29 Authors@R: c(person("Mauricio", "Zambrano-Bigiarini", email="mzb.devel@gmail.com", role=c("aut","cre")), person("Rodrigo", "Rojas", email="Rodrigo.RojasMujica@gmail.com", role=c("ctb")) ) Maintainer: Mauricio Zambrano-Bigiarini <mzb.devel@gmail.com> Description: This package implements a state-of-the-art version of the Particle Swarm Optimisation (PSO) algorithm (SPSO-2011 and SPSO-2007 capable), with a special focus on the calibration of environmental models. hydroPSO is model-independent, allowing the user to easily interface any model code with the calibration engine (PSO). It includes a series of controlling options and PSO variants to fine-tune the performance of the calibration engine to different calibration problems. An advanced sensitivity analysis function together with user-friendly plotting summaries facilitate the interpretation and assessment of the calibration results. Bugs reports/comments/questions are very welcomed. diff --git a/NEWS b/NEWS index a942a103ebe76e2290f8355d0a6f6c27fdc0652f..46657ace0e70dd854d45a91d0150b11ff63266b3 100755 --- a/NEWS +++ b/NEWS @@ -8,7 +8,8 @@ NEWS/ChangeLog for hydroPSO * new confinement of the velocity ( V[t+1] = -0.5 * V[t], when x[t+1] > x_max | x[t+1] < x_min ) * optional normalisation of parameter values - -) improved performance (~ 33% faster, tested on 10-D benchmark functions with 'write2disk=FALSE') + -) improved performance. ~ 33% faster for 32-bit machines and 38% faster for 64-bit machines. + Tested on 10-, 20- and 30-D benchmark functions with 'write2disk=FALSE'. -) 'fn' argument now can be any R function or a character. In the latter case, it can be "hydromod" or the name of a valid R function. In previous versions of 'hydroPSO' only a character type was accepted. -) now it handles models with sub-daily time step and with sub-daily observations (thanks to O. Rakovec !). diff --git a/R/PSO_v2012.R b/R/PSO_v2012.R index 7ca22f89388bcccfbf036d7ba26612767d3b4053..189fe8a45e64c5a41399e90d63a9f6c0cd9ce8bb 100755 --- a/R/PSO_v2012.R +++ b/R/PSO_v2012.R @@ -246,8 +246,6 @@ compute.veloc <- function(x, v, w, c1, c2, CF, Pbest, part.index, gbest, } else Gr <- (x + p) / 2 vn <- CF * (w*v + alea.sphere( G=Gr, radius= enorm(Gr-x) ) - x ) - - #vn <- CF * (w*v + gx + alea.sphere(G=gx + x, radius=enorm(gx) ) ) } else if ( method %in% c("spso2007", "canonical") ) { @@ -983,7 +981,7 @@ InitializateV <- function(npart, param.IDs, x.MinMax, v.ini.type, Xini) { # Started: 24-Dec-2010 ## # Updates: 29-Dec-2010 ; ## # 14-Nov-2011 ; 27-Jan-2011 ## -# 28-Oct-2012 ## +# 28-Oct-2012 ; 29-Oct-2012 ## ################################################################################ # Purpose: Function for computing the best value in the neighbourhood of each # particle @@ -1013,17 +1011,18 @@ UpdateLocalBest <- function(pbest.fit, localBest.pos, localBest.fit, x.neighbour if(MinMax == "max") { better.index <- which( pbest.fit[neighs.index] > localBest.fit[i] ) } else better.index <- which( pbest.fit[neighs.index] < localBest.fit[i] ) - - # if there are some particles that have a better fitness value - if (length(better.index) > 0) #{ ??? - if(MinMax == "max") { - localBest.fit[i] <- max( pbest.fit[neighs.index], na.rm=TRUE ) - } else localBest.fit[i] <- min( pbest.fit[neighs.index], na.rm=TRUE ) + + if (length(better.index) > 0) { - if(MinMax == "max") { - localBest.pos[i] <- neighs.index[which.max( pbest.fit[neighs.index] )] - } else localBest.pos[i] <- neighs.index[which.min( pbest.fit[neighs.index] )] - #} ??? + if(MinMax == "max") { + localBest.pos[i] <- neighs.index[which.max( pbest.fit[neighs.index] )] + localBest.fit[i] <- pbest.fit[localBest.pos[i]] + } else { + localBest.pos[i] <- neighs.index[which.min( pbest.fit[neighs.index] )] + localBest.fit[i] <- pbest.fit[localBest.pos[i]] + } # ELSE end + } # |IF end + } # FOR end