diff --git a/DESCRIPTION b/DESCRIPTION index 88b0688930c862d2b3f3abb38018ee0a5f16e5e2..bc33681ddc7789a66e84d68d36687237cac500bc 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-27 -Date: 2012-11-20 +Version: 0.1-58-28 +Date: 2012-11-21 Authors@R: c(person("Mauricio", "Zambrano-Bigiarini", email="mzb.devel@gmail.com", role=c("aut","cre"), comment="feel free to write me in English, Spanish or Italian"), 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 c816a78aec8b39734a311e8a955d71e57e98edb7..8672155ac26f6dbdaf4934c6565c207581bea603 100755 --- a/NEWS +++ b/NEWS @@ -92,6 +92,8 @@ NEWS/ChangeLog for hydroPSO 'sgriewank' : shifted Griewank (CEC 2005), 'sackley' : shifted Ackley (CEC 2005), 'sschwefel1_2': shifted Schwefel's Problem 1.2 (CEC 2005) + + -) added equations, description and references for each test function. o 'plot_convergence': -) the label 'Gbest' was replaced by "Global Optimum' in the title of the plot and in the label of the 'y' axis, in order to make it more intuitive to people non-familiar with PSO diff --git a/R/test_functions.R b/R/test_functions.R index 83fa342fc86d4ed1aad17c39f1756e99e844e699..e15c353db5a926998c5a01e76bdb8b43d91d666d 100755 --- a/R/test_functions.R +++ b/R/test_functions.R @@ -14,16 +14,28 @@ sinc <- function(x) { return( prod (sin( pi*(x-seq(1:n)) ) / ( pi*(x-seq(1:n)) ), na.rm=TRUE) ) } # 'sinc' END -# MZB, RR, 21-Jun-2011, 14-Nov-2011 + +# MZB, RR, 21-Jun-2011, 14-Nov-2011 ; 21-Nov-2012 # Rosenbrock function: f(1,..,1)=0. Minimization. In [-30, 30]^n. AcceptableError < 100 +# Properties : Unimodal, Non-separable +# Description: The Rosenbrock function is non-convex, unimodal and non-separable. +# It is also known as \emph{Rosenbrock's valley} or \emph{Rosenbrock's banana} function. +# The global minimum is inside a long, narrow, parabolic shaped flat valley. +# To find the valley is trivial. To converge to the global minimum, however, is difficult. +# It only has one optimum located at the point \preformatted{o =(1,...,1)}. +# It is a quadratic function, and its search range is [−30, 30] for each variable. +# Ref: http://en.wikipedia.org/wiki/Rosenbrock_function, http://www.it.lut.fi/ip/evo/functions/node5.html rosenbrock <- function(x) { n <- length(x) - return( sum( ( 1- x[1:(n-1)] )^2 + 100*( x[2:n] - x[1:(n-1)]^2 )^2 ) ) + return( sum( 100*( x[2:n] - x[1:(n-1)]^2 )^2 + ( x[1:(n-1)] - 1 )^2 ) ) } # 'rosenbrock' END -# MZB, RR, 21-Jun-2011 +# MZB, RR, 21-Jun-2011; 21-Nov-2012 # Sphere function: f(1,..,1)=0. Minimization. In [-100, 100]^n. AcceptableError < 0.01 +# Properties : Unimodal, additively separable +# Description: The Sphere test function is one of the most simple test functions available in the specialized literature. This unimodal and separable test function can be scaled up to any number of variables. It belongs to a family of functions called quadratic functions and only has one optimum in the point o = (0,...,0). The search range commonly used for the Sphere function is [−100, 100] for each decision variable. +# Reference : http://www.it.lut.fi/ip/evo/functions/node2.html sphere <- function(x) { return(sum(x^2)) } # 'sphere' END @@ -36,16 +48,23 @@ rastrigrin <- function(x) { return( 10*n + sum( x^2 - 10*cos(2*pi*x) ) ) } # 'rastrigrin' END -# MZB, RR, 17-Jul-2012. The correct name of the function is 'Rastrigin' and NOT 'Rastrigrin' !!! +# MZB, RR, 17-Jul-2012. 21-Nov-2012. The correct name of the function is 'Rastrigin' and NOT 'Rastrigrin' !!! # Rastrigin function: f(0,..,0)=0. Minimization. In [-5.12, 5.12]^n. AcceptableError < 100 +# Properties : Multimodal, additively separable +# Description: The generalized Rastrigin test function is non-convex and multimodal. It has several local optima arranged in a regular lattice, but it only has one global optimum located at the point \preformatted{o=(0,...,0)}. The search range for the Rastrigin function is [-5.12, 5.12] in each variable. This function is a fairly difficult problem due to its large search space and its large number of local minima +# Reference : http://www.it.lut.fi/ip/evo/functions/node6.html, http://en.wikipedia.org/wiki/Rastrigin_function rastrigin <- function(x) { n <- length(x) return( 10*n + sum( x^2 - 10*cos(2*pi*x) ) ) } # 'rastrigin' END -# MZB, RR, 21-Jun-2011 +# MZB, RR, 21-Jun-2011 ; 21-Nov-2012 # Griewank function: f(0,..,0)=0. Minimization. In [-600, 600]^n. AcceptableError < 0.05 +# Properties : +# Description: The Griewank test function is multimodal and non-separable, with has several local optima within the search region defined by [-600, 600]. It is similar to the Rastrigin function, but the number of local optima is larger in this case. It only has one global optimum located at the point \kbd{o=(0,...,0)}. While this function has an exponentially increasing number of local minima as its dimension increases, it turns out that a simple multistart algorithm is able to detect its global minimum more and more easily as the dimension increases (Locatelli, 2003) +# Reference : http://www.geatbx.com/docu/fcnindex-01.html +# Locatelli, M. 2003. A note on the griewank test function, Journal of Global Optimization, 25 (2), 169-174, doi:10.1023/A:1021956306041 griewank <- function(x) { n <- length(x) return( 1 + (1/4000)*sum( x^2 ) - prod( cos( x/sqrt(seq(1:n)) ) ) ) @@ -59,8 +78,11 @@ schafferF6 <- function(x) { } # 'schafferF6' END -# MZB, RR, 14-Nov-2011 +# MZB, RR, 14-Nov-2011, 21-Nov-2012 # Ackley function: f(0,..,0)=0. Minimization. In [-32.768, 32.768]^n. AcceptableError < 0.01, a=20 ; b=0.2 ; c=2*pi +# Properties : Multimodal, Separable +# Description: The Ackley test function is multimodal and separable, with several local optima that, for the search range [-32, 32], look more like noise, although they are located at regular intervals. The Ackley function only has one global optimum located at the point o=(0,...,0). +# Reference : http://www.it.lut.fi/ip/evo/functions/node14.html ackley <- function(x) { n <- length(x) return( -20*exp( -0.2*sqrt((1/n)*sum(x^2)) ) - exp( (1/n)*sum(cos(2*pi*x)) ) + 20 + exp(1) ) diff --git a/man/test_functions.Rd b/man/test_functions.Rd index 7e9e6d61c3f6051d73a576fc1db2403322f3292f..9e3fd838a4b0dfe92fe30516d8f637189c327cdd 100755 --- a/man/test_functions.Rd +++ b/man/test_functions.Rd @@ -54,9 +54,40 @@ numeric shifting vector to be used, with the same length of \code{x} numeric with the bias to be imposed } } -%\details{ -%\code{Ackley} -%} +\details{ +The \bold{Ackley} test function is multimodal and separable, with several local optima that, for the search range [-32, 32], look more like noise, although they are located at regular intervals. The Ackley function only has one global optimum located at the point \kbd{o=(0,...,0)}. It is defined by: +\deqn{ ackley = 20+\exp(1)-20\exp\left( -0.2\sqrt{\frac{1}{n}\sum_{i=1}^{n}x_{i}^2} \right)-\exp\left(\frac{1}{\textcolor{red}{n}}\sum_{i=1}^{n}\cos(2\pi x_{i})\right) ; -32 \leq x_i \leq 32 \ ; \ i=1,2,\ldots,n } + + +The generalized \bold{Rastrigin} test function is non-convex, multimodal and additively separable. It has several local optima arranged in a regular lattice, but it only has one global optimum located at the point \kbd{o=(0,...,0)}. The search range for the Rastrigin function is [-5.12, 5.12] in each variable. This function is a fairly difficult problem due to its large search space and its large number of local minima. It is defined by: + +\deqn{ rastrigin = 10n+\sum_{i=1}^{n}\left[x_{i}^{2}-10\cos(2\pi x_{i})\right] \ ; \ -5.12 \leq x_i \leq 5.12 \ ; \ i=1,2,\ldots,n } + + +The \bold{Griewank} test function is multimodal and non-separable, with has several local optima within the search region defined by [-600, 600]. It is similar to the Rastrigin function, but the number of local optima is larger in this case. It only has one global optimum located at the point \kbd{o=(0,...,0)}. While this function has an exponentially increasing number of local minima as its dimension increases, it turns out that a simple multistart algorithm is able to detect its global minimum more and more easily as the dimension increases (Locatelli, 2003). It is defined by: + +\deqn{ griewank = \frac{1}{4000}\sum_{i=1}^{n}x_{i}^{2}-\prod_{i=1}^{n}\cos\left(\frac{x_i}{\sqrt{i}}\right)+1 \ ; \ -600 \leq x_i \leq 600 \ ; \ i=1,2,\ldots,n } + + +The \bold{Rosenbrock} function is non-convex, unimodal and non-separable. It is also known as \emph{Rosenbrock's valley} or \emph{Rosenbrock's banana} function. The global minimum is inside a long, narrow, parabolic shaped flat valley. To find the valley is trivial. To converge to the global minimum, however, is difficult. It only has one optimum located at the point \kbd{o=(1,...,1)}. It is a quadratic function, and its search range is [-30, 30] for each variable. It is defined by: + +\deqn{ rosenbrock = \sum_{i=1}^{n-1}\left[100(x_{i+1}\textcolor{red}{-}x_{i}^{2})^{2}+(1-x_{i})^{2}\right] \ ; \ -30 \leq x_i \leq 30 \ ; \ i=1,2,\ldots,n } + + +\deqn{ schafferF6 = 0.5+\frac{\sin^{2}\sqrt{\textcolor{red}{\sum_{i=1}^{n}}x_{i}^{2}}-0.5}{(1+0.001\textcolor{red}{\sum_{i=1}^{n}}x_{i}^{2})^{2}} \ ; \ -100 \leq x_i \leq 100 \ ; \ i=1,2,\ldots,n } + +The \bold{Sphere} test function is one of the most simple test functions available in the specialized literature. This unimodal and additively separable test function can be scaled up to any number of variables. It belongs to a family of functions called quadratic functions and only has one optimum in the point \kbd{o=(0,...,0)}. The search range commonly used for the Sphere function is [-100, 100] for each decision variable. It is defined by: +\deqn{ sphere = \sum_{i=1}^{n} x_{i}^2 \ ; \ -100 \leq x_i \leq 100 \ ; \ i=1,2,\ldots,n } + + +\deqn{ sackley = 20+\exp(1)-20\exp\left(-0.2\sqrt{\frac{1}{n}\sum_{i=1}^{n}z_{i}^2}\right)-\exp\left(\frac{1}{n}\sum_{i=1}^{n}\cos(2\pi z_{i})\right) + f\_bias , z=x-o ; \ i=1,2,\ldots,n } + + +\deqn{ sgriewank = \frac{1}{4000}\sum_{i=1}^{n}z_{i}^{2}-\prod_{i=1}^{n}\cos\left(\frac{z_i}{\sqrt{i}}\right)+1 + f\_bias \ , \ z=x-o ; \ i=1,2,\ldots,n } + +\deqn{ ssphere = \sum_{i=1}^{n} z_{i}^2 + f\_bias \ , \ z=x-o ; \ i=1,2,\ldots,n }{% +sphere = sum( x^2 ) } +} \value{ Each test function returns a single numeric value corresponding to the function evaluated on the vector \code{x} %% If it is a LIST, use @@ -66,9 +97,6 @@ Each test function returns a single numeric value corresponding to the function } \references{ -Test Functions for Unconstrained Global Optimization \cr -\cite{\url{http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO_files/Page364.htm}} - GEATbx: Example Functions (single and multi-objective functions) \cr \cite{\url{http://www.geatbx.com/docu/fcnindex-01.html}} @@ -82,6 +110,19 @@ Benchmark Problems \cr \cite{\url{http://www.zsd.ict.pwr.wroc.pl/files/docs/functions.pdf}} +Test Functions for Unconstrained Global Optimization \cr +\cite{\url{http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO_files/Page364.htm}} + +Rosenbrock: \cite{\url{http://www.it.lut.fi/ip/evo/functions/node5.html}}, \cite{\url{http://en.wikipedia.org/wiki/Rosenbrock_function}} + +Sphere: \cite{\url{http://www.it.lut.fi/ip/evo/functions/node2.html}} + +Rastrigin: \cite{\url{http://www.it.lut.fi/ip/evo/functions/node6.html}}, \cite{\url{http://en.wikipedia.org/wiki/Rastrigin_function}} + +Ackley: \cite{\url{http://www.it.lut.fi/ip/evo/functions/node14.html}} + +Griewank: \cite{Locatelli, M. 2003. A note on the griewank test function, Journal of Global Optimization, 25 (2), 169-174, doi:10.1023/A:1021956306041} + } \author{ Mauricio Zambrano-Bigiarini, \email{mzb.devel@gmail.com}