Learn R Programming

hydroPSO (version 0.3-1-1)

ReadPlot_GofPerParticle: plotParticlesGof

Description

This function reads/plots the parameter values of each particle and the objective function against the iteration number

Usage

read_GofPerParticle(file="Particles_GofPerIter.txt", na.strings="NA", 
     plot=TRUE, ptype="one", nrows="auto", main=NULL, 
     xlab="Number of Iterations", cex=0.4, cex.main=1.5, cex.axis=1.7, 
     cex.lab=1.5, col, lty=3, ylim, verbose=TRUE, do.png=FALSE, 
     png.width=1500, png.height=900, png.res=90, 
     png.fname="Particles_GofPerIter.png")
                 
plot_GofPerParticle(x, ptype="one", nrows="auto", main=NULL, 
     xlab="Number of Iterations", cex=0.4, cex.main=1.5, cex.axis=1.7, 
     cex.lab=1.5, col=rainbow(ncol(x)), lty=3, ylim=NULL, verbose=TRUE, ...,
     do.png=FALSE, png.width=1500, png.height=900, png.res=90, 
     png.fname="Particles_GofPerIter.png")

Arguments

file
character, name (including path) of the file to be read
na.strings
character vector, strings which are to be interpreted as NA values. See read.table
plot
logical, indicates if a plot with the convergence measures has to be produced
x
data.frame with the goodness-of-fit measure of each particle per iteration. The number of columns in x has to be equal to the number of particles, whereas the number of rows in x has to be equal to the number of iterations ( (<
ptype
character, representing the type of plot. Valid values are: in c("one", "many"), for plotting all the particles in the smae figure or in one windows per particle, respectively
nrows
OPTIONAL. Only used when plot=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 x
main
OPTIONAL. Only used when plot=TRUE character, title for the plot
xlab
OPTIONAL. Only used when plot=TRUE character, label for the 'x' axis
cex
OPTIONAL. Only used when plot=TRUE numeric, values controlling the size of text and points with respect to the default
cex.main
OPTIONAL. Only used when plot=TRUE numeric, magnification for main titles relative to the current setting of cex
cex.axis
OPTIONAL. Only used when plot=TRUE numeric, magnification for axis annotation relative to the current setting of cex
cex.lab
OPTIONAL. Only used when plot=TRUE numeric, magnification for x and y labels relative to the current setting of cex
col
OPTIONAL. Only used when plot=TRUE character, colour to be used for drawing the lines
lty
OPTIONAL. Only used when plot=TRUE numeric, line type to be used
ylim
numeric with the the y limits of the plot
verbose
logical, if TRUE, progress messages are printed
...
OPTIONAL. Only used when plot=TRUE further arguments passed to the plot command or from other methods
do.png
logical, indicates if all the figures have to be saved into PNG files instead of the screen device
png.width
OPTIONAL. Only used when do.png=TRUE numeric, width of the PNG device. See png
png.height
OPTIONAL. Only used when do.png=TRUE numeric, height of the PNG device. See png
png.res
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
png.fname
OPTIONAL. Only used when do.png=TRUE character, filename used to store the PNG file wih the dotty plots of the parameter values

See Also

read_results, plot_results, plot_2parOF, plot_NparOF, plot_ParamsPerIter

Examples

Run this code
# 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 convergence measures got by running hydroPSO
setwd("PSO.out")
read_GofPerParticle() # all the particles in the same window
read_GofPerParticle(ptype="many") # each particle in a different pannel

Run the code above in your browser using DataLab