Skip to content
Snippets Groups Projects
Commit 7c1ad600 authored by Mauricio Zambrano-Bigiarini's avatar Mauricio Zambrano-Bigiarini
Browse files

hydroPSO.R: fixed velocity equation for 'method=canonical'.

parent c7eb141a
No related branches found
No related tags found
No related merge requests found
...@@ -215,7 +215,7 @@ compute.CF <- function(c1, c2) { ...@@ -215,7 +215,7 @@ compute.CF <- function(c1, c2) {
################################################################################ ################################################################################
# Created: 2008 # # Created: 2008 #
# Updates: Oct-2011 ; Nov-2011 # # Updates: Oct-2011 ; Nov-2011 #
# 19-Sep-2012 ; 20-Sep-2012 ; 28-Oct-2012 # # 19-Sep-2012 ; 20-Sep-2012 ; 28-Oct-2012 ; 31-Oct-2012 #
################################################################################ ################################################################################
compute.veloc <- function(x, v, w, c1, c2, CF, Pbest, part.index, gbest, compute.veloc <- function(x, v, w, c1, c2, CF, Pbest, part.index, gbest,
topology, method, MinMax, neighs.index, topology, method, MinMax, neighs.index,
...@@ -241,7 +241,7 @@ compute.veloc <- function(x, v, w, c1, c2, CF, Pbest, part.index, gbest, ...@@ -241,7 +241,7 @@ compute.veloc <- function(x, v, w, c1, c2, CF, Pbest, part.index, gbest,
vn <- CF * (w*v + alea.sphere( G=Gr, radius= enorm(Gr-x) ) - x ) vn <- CF * (w*v + alea.sphere( G=Gr, radius= enorm(Gr-x) ) - x )
} else if ( method %in% c("spso2007", "canonical") ) { } else if ( method == "spso2007" ) {
if( part.index != localBest.pos) { if( part.index != localBest.pos) {
vn <- CF * ( w*v + r1*c1*(pbest-x) + r2*c2*(localBest-x) ) vn <- CF * ( w*v + r1*c1*(pbest-x) + r2*c2*(localBest-x) )
...@@ -292,8 +292,12 @@ compute.veloc <- function(x, v, w, c1, c2, CF, Pbest, part.index, gbest, ...@@ -292,8 +292,12 @@ compute.veloc <- function(x, v, w, c1, c2, CF, Pbest, part.index, gbest,
wght <- (1/lpbest.fit)/sum(1/lpbest.fit) wght <- (1/lpbest.fit)/sum(1/lpbest.fit)
} else wght <- lpbest.fit/sum(lpbest.fit) } else wght <- lpbest.fit/sum(lpbest.fit)
vn <- CF * ( w*v + (1/N) * colSums( wght*r*(P-X) ) ) vn <- CF * ( w*v + (1/N) * colSums( wght*r*(P-X) ) )
} # ELSE end
} else if ( method == "canonical")
vn <- CF * ( w*v + r1*c1*(pbest-x) + r2*c2*(localBest-x) )
return(vn) return(vn)
......
...@@ -38,12 +38,17 @@ further arguments to be passed to \code{fn}. ...@@ -38,12 +38,17 @@ further arguments to be passed to \code{fn}.
character, variant of the PSO algorithm to be used. By default \code{method='spso2011'}, while valid values are in \code{c('spso2011', 'spso2007', 'ipso', 'fips', 'wfips', 'canonical')}: \cr character, variant of the PSO algorithm to be used. By default \code{method='spso2011'}, while valid values are in \code{c('spso2011', 'spso2007', 'ipso', 'fips', 'wfips', 'canonical')}: \cr
\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{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{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{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{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 \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
\kbd{canonical}: It corresponds to the first formulation of the PSO algorithm, and it is included here for educational and comparative purposes only, due to several limitations described in literature. See Kennedy 2006 \cr \kbd{canonical}: It corresponds to the first formulation of the PSO algorithm, and it is included here for educational and comparative purposes only, due to several limitations described in literature. See Kennedy 2006 \cr
At each iteration particles are attracted to its own best-known \sQuote{personal} and to the best-known position in all the swarm (\sQuote{global}). The following \code{control} arguments are set when this methos is selected: (i) \code{topology='gbest'}, (ii) \code{Xini.type='random'}, (iii) \code{Vini.type='random2007'}, (iv) \code{use.CF=TRUE}, (v) \code{c1=2.05}, (vi) \code{c2=2.05}, (vii) \code{boundary.wall='absorbing2007'}, (viii) \code{lambda=1.0} At each iteration particles are attracted to its own best-known \sQuote{personal} and to the best-known position in all the swarm (\sQuote{global}). The following \code{control} arguments are set when this methos is selected: (i) \code{npart=40}, (ii) \code{topology='gbest'}, (iii) \code{Xini.type='random'}, (iv) \code{Vini.type='random2007'}, (v) \code{use.CF=TRUE}, (vi) \code{c1=2.05}, (vii) \code{c2=2.05}, (viii) \code{boundary.wall='absorbing2007'}, (ix) \code{lambda=1.0}
} }
\item{lower}{ \item{lower}{
numeric, lower boundary for each parameter \cr numeric, lower boundary for each parameter \cr
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment