# NOT RUN {
# Number of dimensions to be optimised
D <- 5
# Boundaries of the search space (Rosenbrock test function)
lower <- rep(-30, D)
upper <- rep(30, D)
# }
# NOT RUN {
# Setting the user's home directory as working directory
setwd("~")
# Setting the seed
set.seed(100)
# Optimising the 'Rosenbrock' test function, and writing the results to text files
hydroPSO(fn=rosenbrock, lower=lower, upper=upper, control=list(write2disk=TRUE) )
# reading the 'Particles.txt' output file of hydroPSO
setwd("PSO.out")
particles <- read_particles(plot=FALSE)
# plotting the value of each parameter and the objective function against the
# values of the objective function
plot_NparOF(params=particles[["part.params"]], gofs=particles[["part.gofs"]],
gof.name="Rosenbrock", alpha=0.5)
# }
Run the code above in your browser using DataLab