hzambran / hydroPSO

Model-Independent Particle Swarm Optimisation for Environmental Models
https://cran.r-project.org/package=hydroPSO
GNU General Public License v2.0
36 stars 18 forks source link

enable parallelPSOCK option to allow SOCK clusters across machines #1

Closed russellpierce closed 9 years ago

russellpierce commented 9 years ago

The previous version of hydroPSO used makeCluster to make PSOCKclusters using the par.nnodes argument. This is very user friendly for single machine cluster users. However, this prevents multi-machine PSOCK cluster users as there is no user friendly way to provide the hostnames to ssh into to spawn the PSOCK instances on other machines.

This code adds a "parallelPSOCK" parallel-type that takes par.hostnames to determine how many nodes are being launched and launches them by hostname.

An example using localhosts only:

FUN2 <- function(x) {matrix(abs(x[1]+x[2])+1,1,1)}
hydroPSO(fn=FUN2, lower=c(-3,1), upper=c(5,2), control=list(write2disk=FALSE,parallel="parallelPSOCK",par.hostnames=rep("localhost",2)))

Items left to fix: The spacing and commenting conventions used were a bit unclear to me, so I just did my best. It may be better to modify them to be consistent with the rest of the code.

russellpierce commented 9 years ago

Additional changes needed