# Number of dimensions to be optimised
nparam <- 4
# 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=rep(-100, nparam), upper=rep(100, nparam),
control=list(npart=2*nparam, 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