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

InitializeV: 'lhs2011' implemented

parent 5420af2f
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
################################################################################ ################################################################################
# Created: 2008 ## # Created: 2008 ##
# Updates: 23-Nov-2010 ## # Updates: 23-Nov-2010 ##
# 20-Sep-2012 ##
################################################################################ ################################################################################
# Purpose : To create a matrix randomly generated, with a bounded uniform distribution # Purpose : To create a matrix randomly generated, with a bounded uniform distribution
...@@ -26,11 +27,11 @@ Random.Bounded.Matrix <- function(npart, x.MinMax) { ...@@ -26,11 +27,11 @@ Random.Bounded.Matrix <- function(npart, x.MinMax) {
upper <- matrix( rep(x.MinMax[,2], npart), nrow=npart, byrow=TRUE) upper <- matrix( rep(x.MinMax[,2], npart), nrow=npart, byrow=TRUE)
# random initialization for all the particles, with a value in [0,1] # random initialization for all the particles, with a value in [0,1]
X <- matrix(runif(n*npart,0,1), nrow=npart, ncol=n) X <- matrix(runif(n*npart, min=0, max=1), nrow=npart, ncol=n)
# Transforming X into the real range defined by the user # Transforming X into the real range defined by the user
X <- lower + (upper-lower)*X X <- lower + (upper-lower)*X
#X <- t( lower + (upper - lower )*t(X) ) #X <- t( lower + (upper - lower )*t(X) ) # when using vector instead of matrixes
return(X) return(X)
...@@ -943,7 +944,12 @@ InitializateV <- function(npart, param.IDs, x.MinMax, v.ini.type, Xini) { ...@@ -943,7 +944,12 @@ InitializateV <- function(npart, param.IDs, x.MinMax, v.ini.type, Xini) {
if ( v.ini.type=="random2011" ) { if ( v.ini.type=="random2011" ) {
V <- matrix(runif(n*npart, min=as.vector(lower-Xini), max=as.vector(upper-Xini)), nrow=npart) V <- matrix(runif(n*npart, min=as.vector(lower-Xini), max=as.vector(upper-Xini)), nrow=npart)
} else if ( v.ini.type=="lhs2011" ) { } else if ( v.ini.type=="lhs2011" ) {
V <- rLHS(npart, x.MinMax - cbind(x.MinMax[,1]-Xini, x.MinMax[,2]-Xini) ) # LHS initialization for all the particles, with a value in [0,1]
require(lhs)
V <- randomLHS(npart, n)
# Transforming V into the real range defined by SPSO-2011
V <- lower + (upper-lower)*V
} # ELSE end } # ELSE end
} else if ( v.ini.type=="random2007" ) { } else if ( v.ini.type=="random2007" ) {
V <- ( Random.Bounded.Matrix(npart, x.MinMax) - Xini ) / 2 V <- ( Random.Bounded.Matrix(npart, x.MinMax) - Xini ) / 2
......
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