From 42e5bd09800c48899902cda1d09962543ec01ad5 Mon Sep 17 00:00:00 2001 From: Mauricio Zambrano-Bigiarini <hzambran@users.noreply.github.com> Date: Thu, 14 Jun 2012 07:50:37 +0000 Subject: [PATCH] changed 'reltol' stopping criterion: 'abs(reltol) <= abs(best.pbest[iter] - best.pbest[iter-1])' --- DESCRIPTION | 4 ++-- NEWS | 9 +++++---- R/PSO_v2012.R | 17 +++++++++++------ man/hydroPSO-package.Rd | 6 +++--- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index aaddf6e..df13e4c 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: hydroPSO Type: Package Title: Model-Independent Particle Swarm Optimisation for Environmental Models Version: 0.1-56 -Date: 2012-06-13 +Date: 2012-06-14 Author: Mauricio Zambrano-Bigiarini [aut, cre] and Rodrigo Rojas [ctb] Author@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> @@ -10,7 +10,7 @@ Description: This package implements a state-of-the-art version of the Particle License: GPL (>=2) Depends: R (>= 2.10.0) Imports: Hmisc, sp, lattice, grid -Suggests: hydroGOF, hydroTSM, lhs, zoo, multicore, scatterplot3d, vioplot +Suggests: hydroGOF(>= 0.3-3), hydroTSM(>= 0.3-0), zoo(>= 1.7-2), xts(>= 0.8-2), lhs, scatterplot3d, vioplot, multicore URL: http://www.rforge.net/hydroPSO, http://cran.r-project.org/web/packages/hydroPSO Classification: optimisation, optimization, calibration, environment, environmental sciences, hydrology, PSO LazyLoad: yes diff --git a/NEWS b/NEWS index 1f70c0c..edd5428 100755 --- a/NEWS +++ b/NEWS @@ -1,12 +1,11 @@ NEWS/ChangeLog for hydroPSO -------------------------- - -0.1-56 13-Jun-2012 +0.1-56 14-Jun-2012 o 'hydroPSO' : -) much less memory consumption for large values of 'maxit' and/or 'npart'. The files 'BestParamPerIter.txt', 'PbestPerIter.txt', 'LocalBestPerIter.txt', 'Velocities.txt' are now written at the end of each iteration, and not at the end of the main algorithm (so the corresponding local variables were removed) - -) the convergence of the algorithm controlled by 'reltol' is now defined by : reltol <= normalised swarm radius, + -) the convergence of the algorithm controlled by 'reltol' is now defined by : abs(reltol) <= abs(best.pbest[iter] - best.pbest[iter-1]), instead of reltol <= [ gbest(iter) / ( gbest(iter-1) +reltol ) ] -) 'PbestPerIter.txt' output file: now it has an additional first column labelled "Iter", with the iteration number -) 'LocalBestPartPerIter.txt' output file: now it has an additional first column labelled "Iter", with the iteration number @@ -15,7 +14,9 @@ NEWS/ChangeLog for hydroPSO (just after the new 'Iter' column) -) minor change: 'gbest.fit.prior' is now initialized in 'gbest.fit' instead of 'gbest.fit + 10*reltol' o 'plot_results': -) 'drty.out' is now checked for existence before reading the results. - + o Specific version numbers were added for the following suggested packages: + hydroGOF(>=0.3-3), hydroTSM(>= 0.3-0), zoo(>=1.7-2), xts(>=0.8-2) + 0.1-55 11-May-2012 o 'hydromod' : -) 'sim' and 'obs' are now checked for time attributes when 'gof.Ini' and/or 'gof.Fin' is/are used diff --git a/R/PSO_v2012.R b/R/PSO_v2012.R index 9effe9c..4be491e 100755 --- a/R/PSO_v2012.R +++ b/R/PSO_v2012.R @@ -1104,7 +1104,7 @@ Random.Topology.Generation <- function(npart, K, # Updates: Dec-2010 # # May-2011 ; 28-Oct-2011 ; 14-Nov-2011 ; 23-Nov-2011 ; # # 15-Jan-2012 ; 23-Jan-2012 ; 30-Jan-2012 ; 23-Feb-2012 ; 23-Mar-2012 # -# 13-Jun-2012 # +# 14-Jun-2012 # ################################################################################ # 'lower' : minimum possible value for each parameter # 'upper' : maximum possible value for each parameter @@ -2126,10 +2126,10 @@ hydroPSO <- function( x.best= X.best.part ) - pbest.fit <- tmp[["pbest"]] - X.best.part <- tmp[["x.best"]] - gbest.fit <- tmp[["gbest.fit"]] - gbest.pos <- tmp[["gbest.pos"]] + pbest.fit <- tmp[["pbest"]] + X.best.part <- tmp[["x.best"]] + gbest.fit <- tmp[["gbest.fit"]] + gbest.pos <- tmp[["gbest.pos"]] } # IF end @@ -2388,7 +2388,12 @@ hydroPSO <- function( ifelse(MinMax=="max", abstol.conv <- gbest.fit >= abstol, abstol.conv <- gbest.fit <= abstol ) - reltol.conv <- ( NormSwarmRadius <= reltol ) + if (reltol==0) { + reltol.conv <- FALSE + } else { + tmp <- abs(pbest.fit.iter.prior - pbest.fit.iter) + ifelse(tmp==0, reltol.conv <- FALSE, reltol.conv <- tmp <= abs(reltol) ) + } # ELSE end pbest.fit.iter.prior <- pbest.fit.iter diff --git a/man/hydroPSO-package.Rd b/man/hydroPSO-package.Rd index e532f7a..7d41ad7 100755 --- a/man/hydroPSO-package.Rd +++ b/man/hydroPSO-package.Rd @@ -23,11 +23,11 @@ The default control arguments in hydroPSO implements the Standard PSO 2007 - SPS \tabular{ll}{ Package: \tab hydroPSO\cr Type: \tab Package\cr -Version: \tab 0.1-55\cr -Date: \tab 2012-05-11\cr +Version: \tab 0.1-56\cr +Date: \tab 2012-06-14\cr License: \tab GPL (>=2)\cr LazyLoad: \tab yes\cr -Packaged: \tab Fri May 11 13:57:44 CEST 2012; MZB \cr +Packaged: \tab Thu Jun 14 09:43:49 CEST 2012; MZB \cr BuiltUnder: \tab R version 2.15.0 (2012-03-30); x86_64-redhat-linux-gnu (64-bit) \cr } %%~~ An overview of how to use the package, including the most important functions ~~ -- GitLab