Description Usage Arguments Value Author(s) See Also Examples
This function reads a file containing different parameter sets and their corresponding goodness-of-fit values
The following values of file
set default values for header
, skip
and param.cols
:
-) modelpara.out, created by the GLUE algorithm of SWAT-CUP,
-) modelpara.beh, created by the GLUE algorithm of SWAT-CUP,
-) goal.sf2, created by the SUFI-2 algorithm of SWAT-CUP
-) goal.pso, created by the PSO algorithm of SWAT-CUP
-) ParameterValues.log, created by Nimbus calibration tool (Lisflood model)
header
and skip
are automatically set, in other case, they need to be provided
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | read_params(file, ...)
## Default S3 method:
read_params(file, header=TRUE, skip=0, param.cols, param.names,
of.col=NULL, of.name="GoF", na.strings="-9999", plot=TRUE,
ptype=c("histogram", "dottyplot", "boxplot", "vioplot", "pairs"),
MinMax=NULL, beh.thr=NA, beh.col="red", beh.lty=1, beh.lwd=2,
nrows="auto", col="#00000030", ylab=of.name, main=NULL, pch=19,
cex=0.5, cex.main=1.5, cex.axis=1.5, cex.lab=1.5,
breaks="Scott", freq=TRUE, verbose=TRUE, ..., do.png=FALSE,
png.width=1500, png.height=900, png.res=90, png.fname="Parameters.png")
plot_params(params, ...)
## Default S3 method:
plot_params(params, gofs=NULL,
ptype=c("histogram", "dottyplot", "boxplot", "vioplot", "pairs"),
param.cols=1:ncol(params), param.names=colnames(params), of.name="GoF",
MinMax=NULL, beh.thr=NA, beh.col="red", beh.lty=1, beh.lwd=2,
nrows="auto", col="#00000030", ylab=of.name, main=NULL, pch=19, cex=0.5,
cex.main=1.5, cex.axis=1.5, cex.lab=1.5, breaks="Scott", freq=TRUE,
verbose=TRUE, ..., do.png=FALSE, png.width=1500, png.height=900,
png.res=90, png.fname="Parameters.png")
## S3 method for class 'data.frame'
plot_params(params, gofs=NULL,
ptype=c("histogram", "dottyplot", "boxplot", "vioplot", "pairs"),
param.cols=1:ncol(params), param.names=colnames(params), of.name="GoF",
MinMax=NULL, beh.thr=NA, beh.col="red", beh.lty=1, beh.lwd=2,
nrows="auto", col="#00000030", ylab=of.name, main=NULL, pch=19, cex=0.5,
cex.main=1.5, cex.axis=1.5, cex.lab=1.5, breaks="Scott", freq=TRUE,
verbose=TRUE, ..., do.png=FALSE, png.width=1500, png.height=900,
png.res=90, png.fname="Parameters.png")
## S3 method for class 'matrix'
plot_params(params, gofs=NULL,
ptype=c("histogram", "dottyplot", "boxplot", "vioplot", "pairs"),
param.cols=1:ncol(params), param.names=colnames(params), of.name="GoF",
MinMax=NULL, beh.thr=NA, beh.col="red", beh.lty=1, beh.lwd=2,
nrows="auto", col="#00000030", ylab=of.name, main=NULL, pch=19, cex=0.5,
cex.main=1.5, cex.axis=1.5, cex.lab=1.5, breaks="Scott", freq=TRUE,
verbose=TRUE, ..., do.png=FALSE, png.width=1500, png.height=900,
png.res=90, png.fname="Parameters.png")
|
file |
character, name (including path) of the file containing the results |
params |
data.frame whose rows represent the values of different parameter sets |
gofs |
OPTIONAL. numeric with the values of goodness-of-fit values for each one of the parameters in |
header |
logical, indicates whether the file contains the names of the variables as its first line |
skip |
numeric (integer), lines of the data file to skip before beginning to read data |
param.cols |
numeric, number of the columns in |
param.names |
character, name of the parameters defined by |
of.col |
OPTIONAL. numeric, number of the column in |
of.name |
OPTIONAL. Only used when |
na.strings |
character, string which is to be interpreted as NA values. |
plot |
logical, indicates if a dotty-plot with the parameter values versus the objective function has to be produced |
ptype |
OPTIONAL. Only used when |
MinMax |
OPTIONAL |
beh.thr |
OPTIONAL |
beh.col |
OPTIONAL. Only used when |
beh.lty |
OPTIONAL. Only used when |
beh.lwd |
OPTIONAL. Only used when |
nrows |
OPTIONAL. Only used when |
col |
OPTIONAL. Only used when |
ylab |
OPTIONAL. Only used when |
main |
chracter, title for the plot |
pch |
OPTIONAL. Only used when |
cex |
OPTIONAL. Only used when |
cex.main |
OPTIONAL. Only used when |
cex.axis |
OPTIONAL. Only used when |
cex.lab |
OPTIONAL. Only used when |
breaks |
breaks used for plotting the histograms of the parameter sets. See |
freq |
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 total area of one). See |
verbose |
logical, if TRUE, progress messages are printed |
... |
OPTIONAL. Only used when |
do.png |
logical, indicates if the plot with the convergence measures has to be saved into a PNG file instead of the screen device |
png.width |
OPTIONAL. Only used when |
png.height |
OPTIONAL. Only used when |
png.res |
OPTIONAL. Only used when |
png.fname |
OPTIONAL. Only used when |
A list with the following elements:
params |
data.frame with the parameter sets tested during the optimisation |
gofs |
numeric with the fitness values computed during the optimisation (each element in 'gofs' corresponds to one row of 'params') |
Mauricio Zambrano-Bigiarini, mzb.devel@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ## Not run:
# 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")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.