R/fitByDDS.R
fitByDDS.Rd
Fit a hydromad model using DDS (Dynamically Dimensioned Search) algorithm.
fitByDDS(
MODEL,
objective = hydromad.getOption("objective"),
control = hydromad.getOption("dds.control"),
save = NULL
)
a model specification created by hydromad
. It
should not be fully specified, i.e one or more parameters should be defined
by ranges of values rather than exact values.
objective function to maximise, given as a
function(Q, X, ...)
. See objFunVal
.
settings for the DDS algorithm. These are the arguments to
optim_dds
.
Optional function(pars,objective value,model)
that will
be called for every model evaluation, for example to save every model run.
the best model from those sampled, according to the given
objective
function. Also, these extra elements are inserted:
the result from SCEoptim
.
the objective
function used.
total number of evaluations of the model simulation function.
timing vector as returned by system.time
.
This function depends on the ppso
package, available from
http://www.rforge.net/ppso/. For alternative optimisation algorithms,
consider fitBySCE
.
Tolson, B. A., and C. A. Shoemaker (2007) Dynamically dimensioned search algorithm for computationally efficient watershed model calibration, Water Resour. Res., 43, W01413, doi:10.1029/2005WR004723. http://www.agu.org/journals/wr/wr0701/2005WR004723/
optim_dds
,fitBySCE
data(Cotter)
x <- Cotter[1:1000]
## IHACRES CWI model with power law unit hydrograph
modx <- hydromad(x, sma = "cwi", routing = "powuh")
modx
#>
#> Hydromad model with "cwi" SMA and "powuh" routing:
#> Start = 1966-05-01, End = 1969-01-24
#>
#> SMA Parameters:
#> lower upper
#> tw 0 100
#> f 0 8
#> scale NA NA
#> l 0 0 (==)
#> p 1 1 (==)
#> t_ref 20 20 (==)
#> Routing Parameters:
#> lower upper
#> a 0.01 60
#> b 0.50 3
#> c 0.50 2
## run with cut-down settings (for a speedy example only!)
foo <- fitByDDS(modx, control = list(
max_number_function_calls = 100,
logfile = NULL,
projectfile = NULL,
load_projectfile = "no"
))
#> Loading required namespace: ppso
#> Warning: Package lhs not installed, lhs_init disabled
summary(foo)
#>
#> Call:
#> hydromad(DATA = x, sma = "cwi", routing = "powuh", a = 6.04208,
#> b = 1.38496, c = 1.78048, tw = 99.7441, f = 4.55294, scale = 0.00127934)
#>
#> Time steps: 900 (0 missing).
#> Runoff ratio (Q/P): (0.7028 / 2.285) = 0.3075
#> rel bias: -4.716e-17
#> r squared: 0.7543
#> r sq sqrt: 0.8364
#> r sq log: 0.8356
#>
#> For definitions see ?hydromad.stats
#>
## return value from DDS:
str(foo$fit.result)
#> List of 4
#> $ value : num -0.854
#> $ par : num [1:5(1d)] 6.04 1.38 1.78 99.74 4.55
#> ..- attr(*, "dimnames")=List of 1
#> .. ..$ : chr [1:5] "a" "b" "c" "tw" ...
#> $ function_calls: num 100
#> $ break_flag : chr "max number of function calls reached"