diff --git a/DESCRIPTION b/DESCRIPTION index 5786b1b89a00a679e6a6229814c3f46bd8224a3b..28de9b5474eb2bb38d9b070c4572141e31350e8b 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,12 +1,12 @@ Package: hydroPSO Type: Package Title: Model-Independent Particle Swarm Optimisation for Environmental Models -Version: 0.1-58-1 -Date: 2012-09-17 +Version: 0.1-58-2 +Date: 2012-09-20 Author: Mauricio Zambrano-Bigiarini [aut, cre] and Rodrigo Rojas [ctb] 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, 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). hydroPSO includes a series of controlling options and PSO variants to fine-tune the performance of the calibration engine. 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. +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. License: GPL (>=2) Depends: R (>= 2.10.0) Imports: Hmisc, sp, lattice, grid diff --git a/R/PSO_v2012.R b/R/PSO_v2012.R index 1b4b608ce1c2bd91975e2c70b135e289d75d8166..938409de94e4a6f1a063e752ee74a7caeb1b9674 100755 --- a/R/PSO_v2012.R +++ b/R/PSO_v2012.R @@ -157,7 +157,8 @@ alea.sphere <- function(G, radius) { # Step 1. Direction l <- 0 - x <- replicate( n, alea.normal(mean=0, sd=1) ) + #x <- replicate( n, alea.normal(mean=0, sd=1) ) + x <- rnorm(n, mean=0, sd=1) l <- sqrt( sum(x*x) ) # Step 2. Random Radius @@ -936,9 +937,9 @@ InitializateV <- function(npart, param.IDs, x.MinMax, v.ini.type, Xini) { n <- length(param.IDs) # 'V' # - # Matrix of velocities for each particles and iteration. - # Rows = 'npart'; - # Columns = 'n' (Dimension of the Solution Space) + # Matrix of velocities for each particle and iteration. + # Rows = 'npart'; + # Columns = 'n' (Dimension of the solution space) # Random bounded values are assigned to each dimension if (v.ini.type %in% c("random2011", "lhs2011") ) { @@ -953,6 +954,9 @@ InitializateV <- function(npart, param.IDs, x.MinMax, v.ini.type, Xini) { V <- randomLHS(npart, n) # Transforming V into the real range defined by SPSO-2011 + lower <- lower - Xini + upper <- upper - Xini + V <- lower + (upper-lower)*V } # ELSE end } else if ( v.ini.type=="random2007" ) { diff --git a/man/hydroPSO.Rd b/man/hydroPSO.Rd index bdaeb12e9da2a5ad85fd6b5645e855e04b6315ec..e05f60e031f13656f680c7f1673fc575f837d3b6 100755 --- a/man/hydroPSO.Rd +++ b/man/hydroPSO.Rd @@ -11,7 +11,7 @@ Enhanced Particle Swarm Optimisation algorithm } \description{ -Particle Swarm Optimisation algorithm to calibrate environmental models. It includes a series of controlling options and PSO variants to improve the performance of the algorithm and customize it to different calibration problems +Particle Swarm Optimisation algorithm to calibrate environmental models. It implements a state-of-the-art Particle Swarm Optimisation (PSO) algorithm (SPSO-2011 and SPSO-2007 capable), with several fine-tuning options and PSO variants available to customise the PSO engine to different calibration problems. } \usage{ hydroPSO(par, fn= "hydromod", ..., method=c("spso2011", "spso2007", "ipso", "fips", "wfips"), @@ -35,14 +35,15 @@ further arguments to be passed to \code{fn}. } \item{method}{ character, variant of the PSO algorithm to be used. Valid values are in \code{c('spso2011', 'spso2007', 'ipso', 'fips', 'wfips')}: \cr - -\kbd{pso}: at each iteration particles are attracted to its own best-known personal and to the best-known global position. Each particle is connected to a neighbourhood of particles depending on the \code{topology} value \cr +f +\kbd{spso2011}: At each iteration particles are attracted to its own best-known \sQuote{personal} and to the best-known position in its \sQuote{local} neighbourhood, which depens on the value of \code{topology}. In addition, values of the PSO engine are set to the values defined in the Standard PSO 2011 (SPSO 2011, see Clerc 2012) \cr +\kbd{spso2007}: As in \code{method='spso2011'}, but with values of the PSO engine set to the values defined in the Standard PSO 2007 (SPSO 2007, see Clerc 2012) \kbd{ipso}: at each iteration particles in the swarm are rearranged in descending order according to their goodness-of-fit and the best \code{ngbest} particles are used to modify particles' position and velocity (see Zhao, 2006). Each particle is connected to a neighbourhood of particles depending on the \code{topology} value \cr \kbd{fips}: at each iteration ALL particles contribute to modify the particles' position and velocity (see Mendes et al., 2004). Each particle is connected to a neighbourhood of particles depending on the \code{topology} value \cr \kbd{wfips}: same implementation as \kbd{fips} method, but the contribution of each particle is weighted according to their goodness-of-fit value (see Mendes et al., 2004) \cr By default \code{method=pso} -\kbd{spso2007}: As in \code{method='pso'}, but with values of the PSO engine set to the values defined in the Standard PSO 2007 (SPSO 2007, see Clerc 2011) \cr -\kbd{spso2011}: As in \code{method='pso'}, but with values of the PSO engine set to the values defined in the Standard PSO 2011 (SPSO 2011, see Clerc 2011) + + } \item{lower}{ numeric, lower boundary for each parameter \cr @@ -149,12 +150,12 @@ By default \code{random.update=TRUE} } \item{boundary.wall}{ character, indicates the type of boundary condition to be applied during optimisation. Valid values are in \code{c('absorbing', 'reflecting', 'damping', 'invisible')} \cr -By default \code{boundary.wall='absorbing'} +By default \code{boundary.wall='absorbing'}\cr Experience has shown that Clerc's constriction factor and the inertia weights do not always confine the particles within the solution space. To address this problem, Robinson and Rahmat-Samii (2004) and Huang and Mohan (2005) propose different boundary conditions, namely, \kbd{reflecting}, \kbd{damping}, \kbd{absorbing} and \kbd{invisible} to define how particles are treated when reaching the boundary of the searching space (see Robinson and Rahmat-Samii (2004) and Huang and Mohan (2005) for further details) } \item{topology}{ -character, indicates the neighbourhood topology used in hydroPSO. Valid values are in \code{c('gbest', 'lbest', 'vonNeumann', 'random')}: \cr +character, indicates the neighbourhood topology used in hydroPSO. Valid values are in \code{c('random', 'gbest', 'lbest', 'vonNeumann')}: \cr \kbd{gbest}: every particle is connected to each other and, hence the global best influences all particles in the swarm. This is also termed \samp{star} topology, and it is generally assumed to have a fast convergence but is more vulnerable to the attraction to sub-optimal solutions (see Kennedy, 1999; Kennedy and Mendes, 2002, Schor et al., 2010) \cr \kbd{lbest}: each particle is connected to its \code{K} immediate neighbours only. This is also termed \samp{circles} or \samp{ring} topology, and generally the swarm will converge slower than the \kbd{gbest} topology but it is less vulnerable to sub-optimal solutions (see Kennedy, 1999; Kennedy and Mendes, 2002) \cr \kbd{vonNeumann}: each particle is connected to its \code{K=4} immediate neighbours only. This topology is more densely connected than \samp{lbest} but less densely than \samp{gbest}, thus, showing some parallelism with \samp{lbest} but benefiting from a bigger neighbourhood (see Kennedy and Mendes, 2003) \cr @@ -443,7 +444,7 @@ hydroPSO( fn="rastrigrin", lower=rep(-5.12, nparam), upper=rep(5.12, nparam), ################################ # Example 3. Gbest Topology # -# (or why is not recommended ) # +# (or why is not recommended !)# ################################ # Setting the seed (for reproducible results)