# Number of dimensions of the optimisation problem
D <- 4
# Boundaries of the search space (Sphere function)
lower <- rep(-100, D)
upper <- rep(100, D)
# Setting the user home directory as working directory
setwd("~")
# Setting the seed
set.seed(100)
# Runing PSO with the 'sphere' test function, writing the results to text files
hydroPSO(fn=sphere, lower=lower, upper=upper,
control=list(maxit=100, write2disk=TRUE, plot=TRUE) )
# 1) reading ALL the parameter sets used in PSO, and histograms (by default)
params <- read_params(file="~/PSO.out/Particles.txt", param.cols=4:7, of.col=3)
# 2) summary of the parameter sets and their goodness-
# plotting the parameter sets as dotty plots
plot_params(params=params[["params"]], gofs=params[["gofs"]],
ptype="dottyplot", main=fn, MinMax="min", freq=TRUE)
# plotting the parameter sets as boxplots
plot_params(params=params[["params"]], ptype="boxplot", MinMax="min")
# plotting the parameter sets as violing plots
library(vioplot)
plot_params(params=params[["params"]], ptype="vioplot", MinMax="min")
# 2) reading only the parameter sets with a goodness-of-fit measure <= 'beh.thr',
# and dotty plots (by default)
params <- read_params(file="~/PSO.out/Particles.txt", param.cols=4:7, of.col=3,
beh.thr=1000, MinMax="min")
Run the code above in your browser using DataLab