This function reads a file containing different parameter sets and ther corresponfing goodness-of-fit values
read_convergence(file="ConvergenceMeasures.txt", MinMax=NULL, beh.thr=NA,
verbose=TRUE, plot=TRUE, col=c("black", "darkolivegreen"), lty=c(1,3),
lwd=c(2,2), main="Global Optimum & Normalized Swarm Radius vs Iteration Number",
xlab="Iteration Number", ylab=c("Global Optimum", expression(delta[norm])),
pch=c(15, 18), cex=1, cex.main=1.4, cex.axis=1.2, cex.lab=1.2,
legend.pos="topright", ..., do.png=FALSE, png.width=1500, png.height=900,
png.res=90,png.fname="ConvergenceMeasures.png")
plot_convergence(x, verbose=TRUE, col=c("black", "darkolivegreen"), lty=c(1,3),
lwd=c(2,2), main="Global Optimum & Normalized Swarm Radius vs Iteration Number",
xlab="Iteration Number", ylab=c("Global Optimum", expression(delta[norm])),
pch=c(15, 18), cex=1, cex.main=1.4, cex.axis=1.2, cex.lab=1.2,
legend.pos="topright", ..., do.png=FALSE, png.width=1500, png.height=900,
png.res=90, png.fname="ConvergenceMeasures.png")
character, name (including path) of the file to be read
logical; if TRUE, progress messages are printed
data.frame with the convergence outputs obtained with read_convergence
.
OPTIONAL
character, indicates if the optimum value in params
corresponds to the minimum or maximum of the the objective function. Valid values are in: c('min', 'max')
numeric, used for selecting only the behavioural parameter sets, i.e., those with a goodness-of-fit value larger/lowervalue than beh.th
, depending on the value of MinMax
.
It is only used for drawing a horizontal line used for separating behavioural from non behavioural parameter sets.
logical, indicates if a plot with the convergence measures has to be produced
OPTIONAL. Only used when plot=TRUE
character, colour to be used for drawing the lines
OPTIONAL. Only used when plot=TRUE
numeric, line type to be used
OPTIONAL. Only used when plot=TRUE
numeric, line width
OPTIONAL. Only used when plot=TRUE
character, label for the 'x' axis
OPTIONAL. Only used when plot=TRUE
character, label for the 'y' axis
OPTIONAL. Only used when plot=TRUE
character, title for the plot
OPTIONAL. Only used when plot=TRUE
numeric, type of symbol for drawing the points of the dotty plots (e.g., 1: white circle)
OPTIONAL. Only used when plot=TRUE
numeric, values controlling the size of text and points with respect to the default
OPTIONAL. Only used when plot=TRUE
numeric, magnification to be used for main titles relative to the current setting of cex
OPTIONAL. Only used when plot=TRUE
numeric, magnification to be used for axis annotation relative to the current setting of cex
OPTIONAL. Only used when plot=TRUE
numeric, magnification to be used for x and y labels relative to the current setting of cex
OPTIONAL. Only used when plot=TRUE
character, position of the legend. Valid values are in c("bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right", "center")
. See legend
OPTIONAL. Only used when plot=TRUE
further arguments passed to the plot command or from other methods
logical, indicates if the plot with the convergence measures has to be saved into a PNG file instead of the screen device
OPTIONAL. Only used when do.png=TRUE
numeric, width of the device. See png
OPTIONAL. Only used when do.png=TRUE
numeric, height of the device. See png
OPTIONAL. Only used when do.png=TRUE
numeric, nominal resolution in ppi which will be recorded in the PNG file, if a positive integer of the device. See png
OPTIONAL. Only used when do.png=TRUE
character, name of the output PNG file. See png
A list with the following elements:
iteration number'
global optimum for each iteration
rate of change of the global optimum (current iter/previous iter)
best performance for the current iteration
normalised swarm radious
gbest: global optimum, mean(pbest): mean values of the personal best of all the particles
# NOT RUN {
# Setting the user home directory as working directory
setwd("~")
# Number of dimensions to be optimised
D <- 4
# Boundaries of the search space (Sphere function)
lower <- rep(-100, D)
upper <- rep(100, D)
# Setting the seed
set.seed(100)
# Runing PSO with the 'sphere' test function, writting the results to text files
hydroPSO(
fn=sphere, lower=lower, upper=upper,
control=list(MinMax="min", write2disk=TRUE, plot=TRUE)
)
# Reading the convergence measures got by running hydroPSO
setwd("PSO.out")
read_convergence()
# }
Run the code above in your browser using DataLab