# NOT RUN {
# Number of dimensions to be optimised
D <- 5
# Boundaries of the search space (Griewank test function)
lower <- rep(-600, D)
upper <- rep(600, D)
# }
# NOT RUN {
# Setting the user's home directory as working directory
setwd("~")
# Setting the seed
set.seed(100)
# Running PSO with the 'griewank' test function, writing the results to text files
hydroPSO(fn=griewank, lower=lower, upper=upper,
control=list(use.IW = TRUE, IW.type= "linear", IW.w= c(1.0, 0.4),
write2disk=TRUE) )
# reading the 'Particles.txt' output file of PSO
setwd("PSO.out")
particles <- read_particles(plot=FALSE)
# plotting the value of each parameter and the objective function against the
# iteration number
plot_ParamsPerIter(particles[["part.params"]])
# }
Run the code above in your browser using DataLab