optimi_stics.RdOptimize STICS parameter values according to measurements
optimi_stics( dir.orig, dir.targ = getwd(), stics, obs_name, Parameters, Vars, weight = NULL, method = c("nmkb"), Plant = 1, max_run = 3, ... )
| dir.orig | Vector or named list of paths to the directory from which to copy the USMs files. |
|---|---|
| dir.targ | Path to the target directory for evaluation. Created if missing. |
| stics | STICS executable path |
| obs_name | A |
| Parameters | A data.frame with parameter name, starting (optional), min, max values, and data type (optional). See details and example. |
| Vars | Output variables on which the optimization is performed |
| weight | The weight used for each variable (see details) |
| method | The optimization method to use, see dfoptim package. For the moment, only |
| Plant | A vector for the plant (i.e. Principal or associated) for which the parameters
will be set (only for plant or technical parameters in mixed crop simulations)
Set to |
| max_run | Maximum number of runs for the optimisation (restart automatically if singular matrix is returned) Default to 3, i.e. two potential restart. |
| ... | Further parameters passed to the optimization function called (see dfoptim package) |
A list of three :
gg_objects: A list of ggplot objects to plot the final STICS simulation with optimized parameter values compared to original parameter values.
opti_output: A named list of the optimized parameter(s) value(s).
last_sim_data: the STICS output from the last simulation with the optimized parameter
values. This data is given using eval_output().
The function uses stats::optimize() for univariate optimization, and the dfoptim package functions for multivariate.
Currently only the Nelder-Mead algorithm is implemented from dfoptim.
The Parameters argument should be formated as a a data.frame (see example).
The start values should exclude the min and max values (they are exclusive bounds).
If the start is NULL, then the mean value between the min and max values is taken. The data type is optional
and only takes double (numeric) or integer. If a parameter is an integer, then a rounding is applied (very crude but functional).
If weight is not provided by the user, the selection criteria is computed using the equation
5 from Wallach et al. (2011). If they are provided, the equation 6 is used instead.
Wallach, D., Buis, S., Lecharpentier, P., Bourges, J., Clastre, P., Launay, M., … Justes, E. (2011). A package of parameter estimation methods and implementation for the STICS crop-soil model. Environmental Modelling & Software, 26(4), 386–394. doi:10.1016/j.envsoft.2010.09.004
if (FALSE) { library(sticRs) Parameters= data.frame(parameter= c('hautK1','hautK2'), start= c(0.2,0.2), min= c(0,0), max= c(1,1)) # On a single USM: optimi_stics(dir.orig = "0-DATA/dummy/Year_2005_2006/IC_Wheat_Pea", dir.targ = "2-Simulations/param_optim", stics = "0-DATA/stics_executable/19-new/Stics.exe", obs_name = c("6_IC_Wheat_N0.obs","6_IC_Pea_N0.obs"), Parameters= Parameters, Vars = c('lai(n)','masec(n)','hauteur'), method= "nmkb",Plant=1) # On a series of USMs: optimi_stics(dir.orig = list(Y2005= "0-DATA/dummy/Year_2005_2006/IC_Wheat_Pea", Y2006= "0-DATA/dummy/Year_2006_2007/IC_Wheat_Pea"), dir.targ = "2-Simulations/param_optim", stics = "0-DATA/stics_executable/19-new/Stics.exe", obs_name = data.frame(Principal= rep("6_IC_Wheat_N0.obs",2), Associated= rep("6_IC_Pea_N0.obs",2)), Parameters = Parameters, weight= 1, Vars = c('hauteur'), method= "nmkb",Plant=c(1,1)) }