read_particles reads the plot_particles takes the parameter sets and their corresponding goodness-of-fit value, read by read_particles, and produces the following plots:
1) Dotty plots
2) Histograms
3) Boxplots
4) Correlation matrix (optional)
5) Empirical CDFs
6) Parameter values vs Number of Model Evaluations
7) (pseudo) 3D dotty plotsread_particles(file="Particles.txt", verbose=TRUE, plot=TRUE,
gof.name="GoF", MinMax=NULL, beh.thr=NA, beh.col="red", beh.lty=1,
beh.lwd=2, nrows="auto", col="black", ylab=gof.name, main=NULL,
pch=19, cex=0.5, cex.main=1.5, cex.axis=1.5, cex.lab=1.5, breaks="Scott", freq=TRUE, do.pairs=FALSE,
dp3D.names="auto", GOFcuts="auto",
colorRamp= colorRampPalette(c("darkred", "red", "orange", "yellow",
"green", "darkgreen", "cyan")), alpha=1, points.cex=0.7,
legend.pos="topleft", do.png=FALSE, png.width=1500,
png.height=900, png.res=90,
dotty.png.fname="Params_DottyPlots.png",
hist.png.fname="Params_Histograms.png",
bxp.png.fname="Params_Boxplots.png",
ecdf.png.fname="Params_ECDFs.png",
runs.png.fname="Params_ValuesPerRun.png",
dp3d.png.fname="Params_dp3d.png",
pairs.png.fname="Params_Pairs.png")
plot_particles(params, gofs, gof.name="GoF", MinMax=NULL, beh.thr=NA,
beh.col="red", beh.lty=1, beh.lwd=2, nrows="auto", col="black",
ylab=gof.name, main=NULL, pch=19, cex=0.5, cex.main=1.5,
cex.axis=1.5, cex.lab=1.5, breaks="Scott", freq=TRUE, do.pairs=FALSE,
weights=NULL, byrow=FALSE, leg.cex=1.5,
dp3D.names="auto", GOFcuts="auto",
colorRamp= colorRampPalette(c("darkred", "red", "orange", "yellow",
"green", "darkgreen", "cyan")), alpha=1, points.cex=0.7,
legend.pos="topleft", verbose=TRUE,
do.png=FALSE, png.width=1500, png.height=900, png.res=90,
dotty.png.fname="Params_DottyPlots.png",
hist.png.fname="Params_Histograms.png",
bxp.png.fname="Params_Boxplots.png",
ecdf.png.fname="Params_ECDFs.png",
runs.png.fname="Params_ValuesPerRun.png",
dp3d.png.fname="Params_dp3d.png",
pairs.png.fname="Params_Pairs.png")
read_velocities(file="Velocities.txt", ... )params (in the same order!)params corresponds to the minimum or maximum of the the objective function. Only used to identify the optimum in the plot
Valid values are in: c('min', 'max')beh.thr, depending on the value of MinMax
By default beh.thr=NA and all the paramplot=TRUE
character, colour for drawing a horizontal line for separating behavioural from non behavioural parameter setsplot=TRUE
numeric, line type for drawing a horizontal line for separating behavioural from non behavioural parameter setsplot=TRUE
numeric, width for drawing a horizontal line for separating behavioural from non behavioural parameter setsplot=TRUE
numeric, number of rows to be used in the plotting window
If nrowsis set to auto, the number of rows is automatically computed depending on the number of columns of paramsplot=TRUE
character, colour for drawing the points of the dotty plotsplot=TRUE
character, label for the 'y' axisplot=TRUE
character, title for the plotplot=TRUE
numeric, type of symbol to be used for drawing the points of the dotty plots (e.g., 1: white circle)plot=TRUE
numeric, values controlling the size of text and points with respect to the defaultplot=TRUE
numeric, magnification for main titles relative to the current setting of cexplot=TRUE
numeric, magnification for axis annotation relative to the current setting of cexplot=TRUE
numeric, magnification for x and y labels relative to the current setting of cexplot=TRUE
further arguments passed to the plot command or from other methodsplot=TRUE
breaks for plotting the histograms of the parameter sets. See histplot=TRUE
logical, if TRUE, the histogram graphic is a representation of frequencies, the counts component of the result; if FALSE, probability densities, component density, are plotted (so that the histogram has a tplot=TRUE
logical, indicates whether a correlation matrix among parameters has to be plotted. If the number of parameter sets tried during the optimisation is large, it may require some time.plot=TRUE
numeric vector, values of the weights to be used for computing the empirical CDFs. See params2ecdfplot=TRUE
logical, indicates whether the computations have to be made for each column or for each row of params. See params2ecdfplot=TRUE
character expansion factor *relative* to current 'par("cex")'. Used for text, and provides the default for 'pt.cex' and 'title.cex'. Default value = 1.2dp3D.names='auto' half the number of parameters in file are chosen randomly for plotting. See <gof.name the colours of the plot have to change. See plot_NparOFplot_NparOFplot_NparOFdo.png=TRUE
numeric, width of the device. See pngdo.png=TRUE
numeric, height of the device. See pngdo.png=TRUE
numeric, nominal resolution in ppi which will be recorded in the PNG file, if a positive integer of the device. See pngdo.png=TRUE
character, filename used to store the PNG file with the dotty plots of the parameter valuesdo.png=TRUE
character, filename used to store the PNG file with the histograms of the parameter valuesdo.png=TRUE
character, filename used to store the PNG file with the boxplots of the parameter valuesdo.png=TRUE
character, filename used to store the PNG file with the empirical CDFs of the parameter valuesdo.png=TRUE
character, filename used to store the PNG file with the parameter values vs the number of model evaluationsdo.png=TRUE
character, filename used to store the PNG file with the pseudo-3D plots of all the parameters defined in dp3D.namesdo.png=TRUE
character, filename used to store the PNG file with the correlation matrix among the parameters and goodness-of-fits measures in params and gofs. See read_particles returns a list with four elements:MinMaxMinMaxread_results, plot_results, read_params, plot_params# Setting the user home directory as working directory
setwd("~")
# Number of dimensions to be optimised
D <- 4
# Boundaries of the search space (Sphere test 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(maxit=100, write2disk=TRUE, plot=TRUE) )
# reading the 'Particles.txt' output file of hydroPSO, and plotting dotty plots,
# histograms, eCDFs, ...
setwd("PSO.out")
particles <- read_particles()
# reading only the particles in 'Particles.txt' with a goodness-of-fit value
# lower than 'beh.thr'
particles <- read_particles(beh.thr=1000, MinMax="min")Run the code above in your browser using DataLab