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

fixed some (very unlikely) error when 'IW.type=aiwf'

parent 4261478a
No related branches found
No related tags found
No related merge requests found
Package: hydroPSO
Type: Package
Title: Model-Independent Particle Swarm Optimisation for Environmental Models
Version: 0.1-58-12
Date: 2012-10-17
Version: 0.1-58-13
Date: 2012-10-22
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.
......
......@@ -46,6 +46,7 @@ NEWS/ChangeLog for hydroPSO
-) when the control argument 'out.with.fit.iter' (not used so far) is set to TRUE, the number of iterations returned
correspond to the effective number of iterations carried out, not the maximum defined by 'maxit'
-) now it is able to correctly write the observed values for sub-daily models
-) fixed some (very unlikely) error when 'IW.type="aiwf"'
o Running 'hydroPSO' >= 0.1-59 with default settings will produce DIFFERENT RESULTS from those obtained with 'hydroPSO' <= 0.1-58, due to the
......
......@@ -363,10 +363,11 @@ compute.value.with.iter <- function(iter, niter, nexp, val.ini, val.fin) {
## compute.w.aiwf Function ##
## Adaptive inertial weight factor (AIWF) ##
################################################################################
# Author : Mauricio Zambrano-Bigiarini
# Author : Mauricio Zambrano-Bigiarini ##
################################################################################
# Started: 2008
# Updates: 24-Nov-2011
# Started: 2008 ##
# Updates: 24-Nov-2011 ##
# 22-Oct-2012 ##
################################################################################
# Reference:
# According to Liu et al., 2005 ("Improved Particle Swarm Combined with Caos")
......@@ -389,14 +390,14 @@ compute.w.aiwf <- function(iter.fit, particle.pos, gbest.fit, w.max, w.min, MinM
f <- iter.fit[particle.pos]
# 'f.avg': mean fitness value of all the particles in the current iteration
f.avg <- mean(iter.fit, na.rm=TRUE)
f.avg <- mean(iter.fit, na.rm=TRUE)
# 'f.min': best fitness value of all the particles in the current iteration
ifelse(MinMax == "min", f.min <- min(iter.fit, na.rm=TRUE), f.min <- max(iter.fit, na.rm=TRUE) )
ifelse(MinMax == "min", to.apply <- (f <= f.avg), to.apply <- (f >= f.avg) )
if (to.apply) {
if ( (to.apply) & (abs(f.avg - f.min)!=0) ) {
w <- w.min + ( ( (w.max - w.min) * abs(f - f.min) ) / abs(f.avg - f.min) )
} else w <- w.max
......@@ -1547,9 +1548,9 @@ hydroPSO <- function(
if (!is.null(n)) {
if (length(lower) != n)
stop( paste( "Invalid argument: 'length(lower) != nparam (", length(lower), "!=", n, ")'", sep="" ) )
stop( "Invalid argument: 'length(lower) != nparam (", length(lower), "!=", n, ")'" )
if (length(upper) != n)
stop( paste( "Invalid argument: 'length(upper) != nparam (", length(lower), "!=", n, ")'", sep="" ) )
stop( "Invalid argument: 'length(upper) != nparam (", length(lower), "!=", n, ")'" )
} else n <- length(lower)
############################################################################
......@@ -1718,13 +1719,13 @@ hydroPSO <- function(
drty.in <- paste( getwd(), "/", drty.in, sep="")
if ( !file.exists( file.path(drty.in) ) )
stop( paste("Invalid argument: The directory '", drty.in, "' doesn't exist !", sep="") )
stop( "Invalid argument: The directory '", drty.in, "' doesn't exist !" )
if (param.ranges == basename(param.ranges) )
param.ranges <- paste( file.path(drty.in), "/", param.ranges, sep="")
if ( !file.exists( param.ranges ) )
stop( paste("Invalid argument: The file '", param.ranges, "' doesn't exist !", sep="") )
stop( "Invalid argument: The file '", param.ranges, "' doesn't exist !" )
if ( is.null(model.FUN) ) {
stop( "'model.FUN' has to be defined !" )
......
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