From 37b148e90867a19589093f59c2b0f3d4408bc336 Mon Sep 17 00:00:00 2001
From: Mauricio Zambrano-Bigiarini <hzambran@users.noreply.github.com>
Date: Mon, 25 Jun 2012 16:37:01 +0000
Subject: [PATCH] hydroPSO: fixed small bug in the new 'random.update'
 parameter

---
 R/PSO_v2012.R | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/R/PSO_v2012.R b/R/PSO_v2012.R
index b4b4259..77ccc07 100755
--- a/R/PSO_v2012.R
+++ b/R/PSO_v2012.R
@@ -1431,7 +1431,7 @@ hydroPSO <- function(
     Xini.type         <- match.arg(control[["Xini.type"]], con[["Xini.type"]]) 
     Vini.type         <- match.arg(control[["Vini.type"]], con[["Vini.type"]]) 
     best.update       <- match.arg(control[["best.update"]], con[["best.update"]]) 
-    random.update     <- as.logical(con[["rand.update"]])
+    random.update     <- as.logical(con[["random.update"]])
     boundary.wall     <- match.arg(control[["boundary.wall"]], con[["boundary.wall"]]) 
     topology          <- match.arg(control[["topology"]], con[["topology"]]) 
     K                 <- con[["K"]]      
@@ -2178,9 +2178,9 @@ hydroPSO <- function(
       ###################   Particles Loop (j) - Start  ########################
       ##########################################################################  
       
-      ifelse(random.update, index <- sample(npart), index <- 1:npart)
+      ifelse(random.update, index.part.upd <- sample(npart), index.part.upd <- 1:npart)
         
-      for (j in index) {
+      for (j in index.part.upd) {
       
         if (write2disk) {
         
-- 
GitLab