| Title: | Multi-Objective Optimisation with Focus on Environmental Models |
|---|---|
| Description: | State-of-the-art Multi-Objective Particle Swarm Optimiser (MOPSO), based on the algorithm developed by Lin et al. (2018) <doi:10.1109/TEVC.2016.2631279> with improvements described by Marinao-Rivas & Zambrano-Bigiarini (2020) <doi:10.1109/LA-CCI48322.2021.9769844>. This package is inspired by and closely follows the philosophy of the single objective 'hydroPSO' R package ((Zambrano-Bigiarini & Rojas, 2013) <doi:10.1016/j.envsoft.2013.01.004>), and can be used for global optimisation of non-smooth and non-linear R functions and R-base models (e.g., 'TUWmodel', 'GR4J', 'GR6J'). However, the main focus of 'hydroMOPSO' is optimising environmental and other real-world models that need to be run from the system console (e.g., 'SWAT+'). 'hydroMOPSO' communicates with the model to be optimised through its input and output files, without requiring modifying its source code. Thanks to its flexible design and the availability of several fine-tuning options, 'hydroMOPSO' can tackle a wide range of multi-objective optimisation problems (e.g., multi-objective functions, multiple model variables, multiple periods). Finally, 'hydroMOPSO' is designed to run on multi-core machines or network clusters, to alleviate the computational burden of complex models with long execution time. |
| Authors: | Rodrigo Marinao-Rivas [aut, cre, cph], Mauricio
Zambrano-Bigiarini [aut, ctb, cph]
|
| Maintainer: | Rodrigo Marinao-Rivas <[email protected]> |
| License: | GPL (>=2) |
| Version: | 0.2-6 |
| Built: | 2026-05-12 23:02:15 UTC |
| Source: | https://gitlab.com/rmarinao/hydromopso |
State-of-the-art Multi-Objective Particle Swarm Optimiser (MOPSO), based on the
algorithm developed by Lin et al. (2018) with improvements described by
Marinao-Rivas and Zambrano-Bigiarini (2020). The package is inspired by the
single objective hydroPSO R package and can be used for global
optimisation of non-smooth and non-linear R functions and base R models (e.g.,
TUWmodel, GR4J, GR6J). It is primarily focused on the
optimisation of environmental and other real-world models that are executed
from the system console (e.g., SWAT+).
hydroMOPSO communicates with an external model through its input and
output files, without requiring changes to the model source code. Thanks to its
flexible design and the availability of several fine-tuning options, it can
tackle a wide range of multi-objective optimisation problems (e.g.,
multi-objective functions, multiple model variables, multiple periods), while
taking advantage of multi-core machines or network clusters to reduce the
computational burden of complex models with long execution time.
| Package: | hydroMOPSO |
| Type: | Package |
| Version: | 0.2-1 |
| Depends: | R (>= 4.0.0) |
| Imports: | zoo, parallel, randtoolbox, lhs, hydroTSM, methods |
| Suggests: | smoof, hydroGOF, airGR, TUWmodel |
| License: | GPL (>=2) |
| LazyLoad: | yes |
| ByteCompile: | TRUE |
| NeedsCompilation: | no |
| Packaged: | Mon Oct 13 01:29:32 -03 2025; rmarinao |
| Repository: | CRAN |
Rodrigo Marinao-Rivas [aut, cre, cph]
Mauricio Zambrano-Bigiarini [aut, ctb, cph]
Oscar Baez-Villanueva [ctb]
Maintainer: Rodrigo Marinao-Rivas [email protected]
Coello, C. A. C., & Lechuga, M. S. (2002). MOPSO: A proposal for multiple objective particle swarm optimization. Proceedings of the 2002 Congress on Evolutionary Computation, CEC 2002, 2, 1051-1056. doi:10.1109/CEC.2002.1004388
Kennedy, J., & Eberhart, R. (1995). Particle swarm optimization. Proceedings of ICNN95 - International Conference on Neural Networks, 4, 1942-1948. doi:10.1109/ICNN.1995.488968
Lin, Q., Li, J., Du, Z., Chen, J., & Ming, Z. (2015). A novel multi-objective particle swarm optimization with multiple search strategies. European Journal of Operational Research, 247, 732-744. doi:10.1016/J.EJOR.2015.06.071
Lin, Q., Liu, S., Zhu, Q., Tang, C., Song, R., Chen, J., ... Zhang, J. (2016). Particle Swarm Optimization With a Balanceable Fitness Estimation for Many-Objective Optimization Problems. IEEE Transactions on Evolutionary Computation, 22, 32-46. doi:10.1109/TEVC.2016.2631279
Marinao-Rivas, R., & Zambrano-Bigiarini, M. (2021). Towards best default configuration settings for NMPSO in multi-objective optimization. 2021 IEEE Latin American Conference on Computational Intelligence, LA-CCI 2021. doi:10.1109/LA-CCI48322.2021.9769844
Zambrano-Bigiarini, M., & Rojas, R. (2013). A model-independent Particle Swarm Optimisation software for model calibration. Environmental Modelling & Software, 43, 5-25. doi:10.1016/j.envsoft.2013.01.004
https://gitlab.com/rmarinao/hydroMOPSO
https://rmarinao.gitlab.io/hydroMOPSO
https://gitlab.com/rmarinao/hydroMOPSO/-/issues
Example wrapper functions to execute the GR4J model and obtain the performance of two objective functions (KGE2012 and KGEGarcia), in a calibration (GR4JExampleCal) or a verification period (GR4JExampleVer). Keep in mind that, within hydroMOPSO, the calibration or verification wrapper functions essentially have to be prepared by the user, with the objective functions that are convenient and the output variables that are necessary.
Thus, the functions presented here are only intended to work with examples from the documentation and serve as a guide to:
1) The general scheme of the calibration/verification wrapper functions
2) The assimilation of mandatory inputs
3) The assimilation of mandatory outputs
GR4JExampleCal(param.values, Obs, Objs.names, var.names, var.units, full.period, warmup.period, cal.period, InputsModel, RunOptions, area) GR4JExampleVer(param.values, Obs, Objs.names, var.names, var.units, full.period, warmup.period, cal.period, InputsModel, RunOptions, area)GR4JExampleCal(param.values, Obs, Objs.names, var.names, var.units, full.period, warmup.period, cal.period, InputsModel, RunOptions, area) GR4JExampleVer(param.values, Obs, Objs.names, var.names, var.units, full.period, warmup.period, cal.period, InputsModel, RunOptions, area)
param.values |
( |
Obs |
( |
Objs.names |
( |
var.names |
( |
var.units |
( |
full.period |
( |
warmup.period |
( |
cal.period |
( |
InputsModel |
( |
RunOptions |
( |
area |
( |
(list)
The returned list contains two elements
(numeric)
Vector with the numerical values of the objectives (GoF1 and GoF2).
(list)
List with as many elements as time series of the output variables of the model (in this case only one output variable: streamflows).
Rodrigo Marinao Rivas [email protected], Mauricio Zambrano-Bigiarini, [email protected]
hydroMOPSO
It runs a user-defined model to be optimised and returns the output variables of the model requested by the user according to the number of functions indicated in the list out.FUNs.
This specific function was designed to run an executable file from the system console
hydromod(param.values, param.files="ParamFiles.txt", param.ranges="ParamRanges.txt", model.drty=getwd(), exe.fname, exe.args = character(), stdout=FALSE, stderr="", verbose= FALSE, out.FUNs, out.FUNs.args )hydromod(param.values, param.files="ParamFiles.txt", param.ranges="ParamRanges.txt", model.drty=getwd(), exe.fname, exe.args = character(), stdout=FALSE, stderr="", verbose= FALSE, out.FUNs, out.FUNs.args )
param.values |
( |
param.files |
character, file name (with full path) storing locations and names of the files that have to be modified for each parameter. By default |
param.ranges |
character, file name (with full path) storing the ranges (maximum and minum values) of the parameters to be used in the optimisation. By default |
model.drty |
( |
exe.fname |
( |
exe.args |
( |
stdout |
( |
stderr |
( |
verbose |
( |
out.FUNs |
( |
out.FUNs.args |
( |
A list with as many output variables (usually time series in zoo class) as functions listed in out.FUNs
Mauricio Zambrano-Bigiarini, [email protected], Rodrigo Marinao Rivas [email protected]
Multi-objective Particle Swarm Optimisation algorithm (NMPSO). The default configuration of hydroMOPSO has been adapted to obtain results with the fewest number of iterations possible.
Important: In Example 5 (calibration of GR4J hydrological model), maxit = 50 was set just for practical needs when testing the package. For acceptable results please change to maxit = 250. With any more robust model and with up to 12 parameters we recommend maxit = 1000.
hydroMOPSO(fn='hydromod', lower=-Inf, upper=Inf, control=list(), model.FUN=NULL, model.FUN.args=list(), BC.space.norm = FALSE, obj.thr = NULL, ...)hydroMOPSO(fn='hydromod', lower=-Inf, upper=Inf, control=list(), model.FUN=NULL, model.FUN.args=list(), BC.space.norm = FALSE, obj.thr = NULL, ...)
fn |
( When |
lower |
( |
upper |
( |
control |
( |
model.FUN |
( |
model.FUN.args |
( |
BC.space.norm |
( |
obj.thr |
( |
... |
further arguments to be passed to |
By default, hydroMOPSO performs minimisation on all objectives specified in fn (MinMax='min' in control list), but this can be changed to maximisation (MinMax='max' in control list). If in fn you have to maximise some objectives and minimise others, you must make them all point to the same direction (all maximising or all minimising), which can be handled simply with a sign (See Example 2 where this type of case is presented).
Although the NMPSO algorithm was formulated to deal with many objectives, the default definitions in hydroMOPSO, and therefore the applications made in research linked to this package, have been made with a focus on two and three objectives. Extending applications to optimisations with four or more objectives is possible with this package (so you are welcome to formulate such problems and solve them with hydroMOPSO!), but be very careful in analyzing your results.
The control argument is a list that can supply any of the following components:
(character)
(OPTIONAL) Used only when fn='hydromod'
Name of the directory storing the input files required for PSO, i.e. ‘ParamRanges.txt’ and ‘ParamFiles.txt’.
(character)
Path to the directory storing the output files generated by hydroMOPSO.
(character)
(OPTIONAL) Used only when fn=='hydromod' | fn=='hydromodInR'
Name of the file defining the minimum and maximum boundary values for each one of the parameters to be optimisated with NMPSO.
(numeric)
(OPTIONAL) Used only when write2disk=TRUE
Number of significant digits used for writing the output files with scientific notation.
(numeric)
number of decimal places used in dominance check. Fewer decimal places (say, 16, 8, or 4, for example) may be necessary to prevent the algorithm from resulting in solutions that are nearly the same.
By default digits.dom=Inf, which basically means numbers are not rounded
(character)
Indicates whether a maximisation or minimisation multi-objetive problem needs to be solved. Valid values are in: c('min', 'max'). By default MinMax='min'. This control argument applies to all objective functions at the same time, so they must all go in the same direction (either all maximizing or all minimizing; keep in mind that for a particular function to go from maximizing to minimizing, or vice versa, it is only necessary add a minus sign (-)).
(numeric)
Number of particles in the swarm. By default npart=10, inherited from R-package hydroMOPSO.
(numeric)
Maximum number of particles to be stored in the updated Pareto Front in each iteration.
By default maxrep=100
(numeric)
Maximum number of Pareto Front particles that, for each iteration, perform the crossing and mutatiom in the application of genetic operators.
By default maxcross=50
(numeric)
Maximum number of iterations.
By default maxit=1000
(character)
Indicates how to initialise the particles' positions in the swarm within the ranges defined by lower and upper.
Valid values are:
-) Sobol: Sobol initialisation of positions, using npart number of samples contained in parameter space bounded by lower and upper. It requires the randtoolbox package
-) lhs: Latin Hypercube initialisation of positions, using npart number of strata to divide each parameter range. It requires the lhs package
-) random: random initialisation of positions within lower and upper
By default Xini.type='Sobol'
(character)
Indicates how to initialise the particles' velocities in the swarm.
Valid values are:
-) zero: all the particles are initialised with zero velocity
-) random2011: random initialisation of velocities within lower-Xini and upper-Xini, as defined in SPSO 2011 (‘Vini=U(lower-Xini, upper-Xini)’) (see Clerc, 2012, 2010)
-) lhs2011: same as in random2011, but using a Latin Hypercube initialisation with npart number of strata instead of a random uniform distribution for each parameter. It requires the lhs package
-) random2007: random initialisation of velocities within lower and upper using the ‘half-diff’ method defined in SPSO 2007 (‘Vini=[U(lower, upper)-Xini]/2’) (see Clerc, 2012, 2010)
-) lhs2007: same as in random2007, but using a Latin Hypercube initialisation with npart number of strata instead of a random uniform distribution for each parameter. It requires the lhs package
By default Vini.type='zero'
(character)
Indicates the type of boundary condition to be applied during optimisation.
Valid values are: absorbing2011, absorbing2007, reflecting, damping, invisible
By default boundary.wall='absorbing2011'
Experience has shown that Clerc's constriction factor and the inertia weights do not always confine the particles within the solution space. To address this problem, Robinson and Rahmat-Samii (2004) and Huang and Mohan (2005) propose different boundary conditions, namely, reflecting, damping, absorbing and invisible to define how particles are treated when reaching the boundary of the searching space (see Robinson and Rahmat-Samii (2004) and Huang and Mohan (2005) for further details).
(logical)
(OPTIONAL)
Indicates whether or not the hypervolume formed between the hyperplane of the Pareto Front and a nadir point designated as nadir.point will be calculated.
By default cal.hv=FALSE
(numeric)
(OPTIONAL) Only required when cal.hv=TRUE
Nadir point from which the hypervolume will be calculated in each iteration step. It should correspond to a reference point considered as the worst acceptable optimal value.
(integer)
(OPTIONAL) Only required when cal.hv=TRUE
Number of points to estimate hypervolume, based on MonteCarlo sampling.
By default n.samples=10000
(logical)
Indicates if the output files will be written to the disk.
By default write2disk=FALSE
(logical)
Indicates if progress messages are to be printed.
By default verbose=TRUE
(logical)
Indicates if a plot with the Pareto Front will be drawn after each iteration.
By default plot=FALSE
(integer)
(OPTIONAL) Used only when verbose=TRUE
The frequency of report messages printed to the screen.
By default REPORT=10
(character)
Indicates how to parallelise ‘hydroMOPSO’ (to be precise, only the evaluation of the objective function fn is parallelised). Valid values are:
-)none: no parallelisation is made (this is the default value)
-)parallel: parallel computations for network clusters or machines with multiple cores or CPUs. A ‘FORK’ cluster is created with the makeForkCluster function. When fn.name='hydromod' the evaluation of the objective function fn is done with the clusterApply function of the parallel package. When fn.name != 'hydromod' the evaluation of the objective function fn is done with the parRapply function of the parallel package.
-)parallelWin: parallel computations for network clusters or machines with multiple cores or CPUs (this is the only parallel implementation that works on Windows machines). A ‘PSOCK’ cluster is created with the makeCluster function. When fn.name='hydromod' the evaluation of the objective function fn is done with the clusterApply function of the parallel package. When fn.name != 'hydromod' the evaluation of the objective function fn is done with the parRapply function of the parallel package.
(numeric)
(OPTIONAL) Used only when parallel!='none'
Indicates the number of cores/CPUs to be used in the local multi-core machine, or the number of nodes to be used in the network cluster.
By default par.nnodes is set to the amount of cores detected by the function detectCores() (parallel package)
(character)
(OPTIONAL) Used only when parallel='parallelWin'
List of package names (as characters) that need to be loaded on each node for allowing the objective function fn to be evaluated.
(list)
The returned list contains elements that vary according to the input specifications
(list)
Particle repository for the last iteration (just second last phase of NMPSO), detailing:
- Position (matrix)
Positions of each set of Pareto Front particles until the last iteration.
- Objs (matrix)
Objective values of each set of Pareto Front particles until the last iteration.
- BFE (numeric)
Balanceable Fitness Estimation (BFE) of each set of Pareto Front particles until the last iteration.
- Ranking.BFE (matrix)
Ranking of each set of Pareto Front particles until the last iteration, according to the BFE value.
(list)
Particle repository history of all iterations (both phases of NMPSO), detailing:
- ParetoFront (data.frame)
History of objectives values of each Pareto Front particles in all iterations (both phases). In this data.frame, the first column indicates the iteration Iter; the second column the phase Phase (1 or 2); and the following columns are as many as objectives treated, being identified with the assigned name.
- Particles_ParetoFront (data.frame)
History of positions of each Pareto Front particles in all iterations (both phases). In this data.frame, the first column indicates the iteration Iter; the second column the phase Phase (1 or 2); then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters).
- MaxMin (data.frame)
Specification on whether the objectives are maximised or minimised.
- ObjsNames (data.frame)
Name of each of the objectives (Obj1, Obj2, ...).
(list)
(ONLY ADDED WHEN fn=='hydromod' | fn=='hydromodInR')
Details about the modeling involved in optimisation:
- Dimensions (data.frame)
Number of objectives and number of output variables involved in the optimisation.
- NamesAndUnitsVars (data.frame)
Name and unit of measure of the output variables involved in the optimisation (var1, var1_unit, var2, var2_unit, ...).
- Obs (list)
Observed values of each of the variables involved in the optimisation, keeping in mind that the same format indicated as mandatory input data Obs within the FUN function is maintained.
- WarmUp (data.frame)
Time series indicating the warm-up period used in the optimisation.
- DatesCal (data.frame)
Time series indicating the calibration period used in the optimisation.
(list)
(ONLY ADDED WHEN fn=='hydromod' | fn=='hydromodInR')
Post-processed results about the modeling involved in optimisation:
- ParticlesFull (data.frame)
History of positions of each Pareto Front particles in all iterations. In this data.frame, the first column indicates the simulation number Sim, in ascending order from the first simulation (first iteration, phase 1) to the last simulation (last iteration, phase 2); then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters).
- FilledPOF (data.frame)
Filled Pareto front, built from evaluating the dominance of the solutions of all the iterations performed in the optimisation. To prevent the filled Pareto Front from having too many solutions, the parameters and objective values are rounded according to input DigitsDom (number of decimal places). In this data.frame, the first column indicates the simulation number Sim; then as many columns as objectives treated, being identified with the assigned name.
- ParticlesFilledPOF (data.frame)
Perticles from filled Pareto Front. In this data.frame, the first column indicates the simulation number Sim; then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters).
- ModelOut (list)
Time series of the model output variables, for all solutions of the filled Pareto Front. This list has as many objects as output variables, and each one corresponds to an object of class zoo with as many columns as solutions of the filled Pareto Front.
- ParticleBestCS (data.frame)
Best compromise solution, i.e., the solution with the minimum Euclidean distance from the maximum values of each objective. data.frame with only one row and several columns: the first column indicates the simulation number Sim; then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters).
- ModelOutBestCS (list)
Time series of the model output variables, just for the best compromise solution. This list has as many objects as output variables, and each one corresponds to an object of class zoo with a single time serie.
- ParticleBestObjs (list)
Solutions that minimise/maximise each of the objectives. data.frame with only one row. In a first level, this list has as many objects as objectives involves in the optimisation, each one with a data.frame with only one row and several columns: the first column indicates the simulation number Sim; then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters).
- ModelOutBestObjs (list)
Time series of the model output variables, for the maximisation/minimisation of each objective. In a first level, this list has as many objects as objectives involves in the optimisation and, in a second level, each one corresponds to a list with as many objects as output variables, each one corresponding to an object of class zoo with a single time serie.
- AnalysisPeriod (character)
String indicating the analysis period, in this case "calibration".
- DigitsDom (numeric)
Number of decimal places used in dominance check. Fewer decimal places (say, 16, 8, or 4, for example) may be necessary to prevent the algorithm from resulting in solutions that are nearly the same.
- ObjsNames (data.frame)
Name of each of the objectives (Obj1, Obj2, ...).
- MaxMin (data.frame)
Specification on whether the objectives are maximised or minimised, must be in c("max", "min").
- Obs (list)
Observed values of each of the variables involved in the optimisation, keeping in mind that the same format indicated as mandatory input data Obs within the FUN function is maintained.
- Dimensions (data.frame)
Number of objectives and number of output variables involved in the optimisation.
- NamesAndUnitsVars (data.frame)
Name and unit of measure of the output variables involved in the optimisation (var1, var1_unit, var2, var2_unit, ...).
- WarmUp (data.frame)
Time series indicating the warm-up period used in the optimisation.
- DatesCal (data.frame)
Time series indicating the calibration period used in the optimisation.
1) For a better understanding of the application cases in which fn=='hydromod' | fn=='hydromodInR', it is strongly recommended to review the complementary tutorials to this package.
Rodrigo Marinao Rivas [email protected], Mauricio Zambrano-Bigiarini [email protected]
Lin, Q., Liu, S., Zhu, Q., Tang, C., Song, R., Chen, J., Coello, C. A. C., Wong, K.-C., & Zhang, J. (2018). Particle Swarm Optimization With a Balanceable Fitness Estimation for Many-Objective Optimization Problems. IEEE Transactions on Evolutionary Computation, 22(1), 32-46. doi:10.1109/TEVC.2016.2631279
Marinao-Rivas, R., & Zambrano-Bigiarini, M. (2021). Towards best default configuration settings for NMPSO in Multiobjective Optimization. 2021 IEEE Latin American Conference on Computational Intelligence. (Accepted).
Zambrano-Bigiarini, M.; R. Rojas (2013), A model-independent Particle Swarm Optimization software for model calibration, Environmental Modelling & Software, 43, 5-25, doi:10.1016/j.envsoft.2013.01.004
Coello, C. A. C., & Lechuga, M. S. (2002). MOPSO: A proposal for multiple objective particle swarm optimization. Proceedings of the 2002 Congress on Evolutionary Computation, CEC 2002, 2, 1051-1056. doi:10.1109/CEC.2002.1004388
Kennedy, J., & Eberhart, R. (1995). Particle swarm optimization. Proceedings of ICNN'95 - International Conference on Neural Networks, 4, 1942-1948. doi:10.1109/ICNN.1995.488968
Deb, K. (1999). Multi-objective genetic algorithms: problem difficulties and construction of test problems. Evolutionary computation, 7, 205-230. doi:10.1162/EVCO.1999.7.3.205
Kursawe, F. (1991). A variant of evolution strategies for vector optimization. Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), 496 LNCS, 193-197. doi:10.1007/BFB0029752
Deb, K., Thiele, L., Laumanns, M., & Zitzler, E. (2005). Scalable Test Problems for Evolutionary Multiobjective Optimization (bll 105-145; A. Abraham, L. Jain, & R. Goldberg, Reds). doi:10.1007/1-84628-137-7_6
############################################################################################### # Example 1. Basic Benchmark function in minimisation ############################################################################################### # This basic Benchmark function has two objectives (M = 2) in minimisation, its Pareto optimal # front is discontinuous with four disconnected curves.This function works with 2 decision # variables (D = 2). # Main reference for function: Deb (1999) library(hydroMOPSO) lower <- c(0, 0) upper <- c(1, 1) fnBasic <- function(param){ x1 <- param[1] x2 <- param[2] obj1 <- x1 obj2 <- (1 + 10*x2)*(1-(x1/(1+10*x2))^2 - x1/(1+10*x2)*sin(2*pi*4*x1)) out <- list(c(obj1, obj2)) # For consistency with further examples, this must be a list names(out) <- "Objs" # The name "Objs" is a mandatory requirement return(out) } set.seed(100) # Setting the seed (for reproducible results) out <- hydroMOPSO(fn = fnBasic, lower = lower, upper = upper, control=list(npart = 10, maxrep = 100, maxcross = 50, MinMax = "min", maxit = 50, plot = TRUE) ) ############################################################################################### # Example 2. Basic Benchmark function in maximisation ############################################################################################### # # This example is identical to Example 1, but the functions are in maximisation # # IMPORTANT: # In the literature related to multi-objective optimisation, test functions are usually # presented with minimisation objectives (such as the function used in Example 1). However, # this does not necessarily always have to be formulated that way, especially when it comes to # real-world applications. # # In this second example we just want to remind you that the disjunctive between maximising or # minimising objectives is "a matter of signs". # # With this in account, as explained in the documentation, for hydroMOPSO operation there is # one requirement which you MUST TAKE CARE OF: # # "The problems must be formulated in such a way that ALL objectives are either maximising or # minimising. If your problem mixes both types of objectives, just add minus signs (-) in the # results that require it..." # # Main reference for function: Kursawe (1991) library(hydroMOPSO) lower <- c(0, 0) upper <- c(1, 1) fnBasic <- function(param){ x1 <- param[1] x2 <- param[2] obj1 <- -( x1 ) obj2 <- -( (1 + 10*x2)*(1-(x1/(1+10*x2))^2 - x1/(1+10*x2)*sin(2*pi*4*x1)) ) # note tha minus sign was added in obj1 and obj2 out <- list(c(obj1, obj2)) # For consistency with further examples, this must be a list names(out) <- "Objs" # The name "Objs" is a mandatory requirement return(out) } set.seed(100) # Setting the seed (for reproducible results) out <- hydroMOPSO(fn = fnBasic, lower = lower, upper = upper, control=list(npart = 10, maxrep = 100, maxcross = 50, MinMax = "max", maxit = 50, plot = TRUE) # note that now MinMax="max" ) ############################################################################################### # Example 3. Using 'smoof' package: Kursawe function ############################################################################################### # # This Benchmark function has two objectives (M = 2), its Pareto optimal front is discontinuous # and non-convex. For this example it will be implemented with 3 decision variables (D = 3) # # Main reference for function: Kursawe (1991) library(hydroMOPSO) library(smoof) D <- 3 lower <- rep(-5,D) upper <- rep(5,D) Kursawe <- smoof::makeKursaweFunction(D) # using 'smoof' package fnKursawe <- function(param){ objs <- Kursawe(x = param) obj1 <- objs[1] obj2 <- objs[2] out <- list(c(obj1, obj2)) # For consistency with further examples, this must be a list names(out) <- "Objs" # The name "Objs" is a mandatory requirement return(out) } set.seed(100) # Setting the seed (for reproducible results) out <- hydroMOPSO(fn = fnKursawe, lower = lower, upper = upper, control=list(npart = 10, maxrep = 100, maxcross = 50, MinMax = "min", maxit = 50, plot = TRUE) ) ############################################################################################### # Example 4. Using 'smoof' package: DTLZ2 function with three objectives ############################################################################################### # # In this example, this Benchmark is formulated with two objectives (M = 3) and 12 decision # variables (D = 12) its Pareto optimal front is concave. # # Main reference for function: Deb (2005) library(hydroMOPSO) library(smoof) M <- 3 D <- 12 lower <- rep(0,D) upper <- rep(1,D) DTLZ2 <- smoof::makeDTLZ2Function(D, M) # using 'smoof' package fnDTLZ2 <- function(param){ objs <- DTLZ2(x = param) obj1 <- objs[1] obj2 <- objs[2] obj3 <- objs[3] out <- list(c(obj1, obj2, obj3)) # For consistency with further examples, this must be a list names(out) <- "Objs" # The name "Objs" is a mandatory requirement return(out) } set.seed(100) # Setting the seed (for reproducible results) out <- hydroMOPSO(fn = fnDTLZ2, lower = lower, upper = upper, control=list(npart = 10, maxrep = 100, maxcross = 50, MinMax = "min", maxit = 50, plot = TRUE) ) ############################################################################################### # Example 5. Calibration of GR4J hydrological model ############################################################################################### # # For this example, a "real-world" problem has been formulated: the calibration of a # hydrological model # # In detail... # Hydrological model: GR4J (Perrin et al., 2004) # Number of parameters: four (X1, X2, X3, X4; see Perrin et al. (2004)) # Study area: Trancura River Basin (RTL) # Input variables: Precipitation (pcp) and Potetntial EvapoTranspiration (pet) # Calibration output variable: Streamflow (qobs) library(hydroMOPSO) library(airGR) library(hydroTSM) library(hydroGOF) # RTL basin ------------------------------------------------ basin.area <- 1415025887 # basin area in square meters # Load time series ----------------------------------------- data(Trancura9414001plus) # Load RTL data set # Dates ---------------------------------------------------- dates.raw <- Trancura9414001plus[,"Date"] dates <- as.Date(dates.raw) # dates # INPUTS time series --------------------------------------- # Precipitation (input variable) ts.pcp.raw <- Trancura9414001plus[,"P_mm"] ts.pcp <- zoo(ts.pcp.raw, dates) # Potential EvapoTranspiration (input variable) ts.pet.raw <- Trancura9414001plus[,"PET_mm"] ts.pet <- zoo(ts.pet.raw, dates) # OUTPUTS time series -------------------------------------- # Observed streamflow (calibration output variable) ts.qobs.raw <- Trancura9414001plus[,"Qobs_m3s"] ts.qobs <- zoo(ts.qobs.raw, dates) # Parameter ranges and noCal parameters -------------------- lower <- c("X1" = 0.01, "X2" = -100, "X3" = 0.01, "X4" = 0.5) # parameter range lower threshold upper <- c("X1" = 1200, "X3" = 100, "X3" = 5000, "X4" = 5 ) # parameter range upper threshold noCal.param <- (lower + upper)/2 # uncalibrated parameters # Names and units of observed output variables ------------- char.obs.names <- "Streamflow" char.obs.units <- "m3/s" # Objectives names ----------------------------------------- char.objs.names <- c("KGE2012_Q", "KGEGarcia_Q") # Calibration dates and subsetting ------------------------- WarmUpCal.dates <- dip("1979-01-01", "1979-12-31") # WarmUp for Calibration Cal.dates <- dip("1980-01-01", "1999-12-31") # Calibration FullCal.dates <- dip("1979-01-01", "1999-12-31") # WarmUp + Calibration start.FullCal <- FullCal.dates[1] end.FullCal <- FullCal.dates[length(FullCal.dates)] # INPUTS time series --------------------------------------- # Precipitation (input variable) ts.pcp.FullCal <- window(ts.pcp, start = start.FullCal, end = end.FullCal) # subsetting pcp # Potential EvapoTranspiration (input variable) ts.pet.FullCal <- window(ts.pet, start = start.FullCal, end = end.FullCal) # subsetting pet # OUTPUTS time series -------------------------------------- # Observed streamflow (calibration output variable) ts.qobs.FullCal <- window(ts.qobs, start = start.FullCal, end = end.FullCal) # subsetting qobs list.obs.Cal <- list(Q = ts.qobs.FullCal) # Structuring Inputs and Options of GR4J model ------------- InputsModel.Cal <- CreateInputsModel(FUN_MOD= RunModel_GR4J, DatesR= as.POSIXlt(FullCal.dates), Precip= coredata(ts.pcp.FullCal), PotEvap= coredata(ts.pet.FullCal)) RunOptions.Cal <- CreateRunOptions(FUN_MOD= RunModel_GR4J, InputsModel= InputsModel.Cal, IndPeriod_Run = 1:length(FullCal.dates), warnings = FALSE) # hydroMOPSO calibration ----------------------------------- set.seed(100) # Setting the seed (for reproducible results) Cal.results <- hydroMOPSO(fn="hydromodInR", lower=lower, upper=upper, control=list(MinMax="max", Xini.type = "lhs", npart=10, maxit=50, # for better results set maxit=250 in this case maxrep = 100, maxcross = 50, maxeval = 15000, write2disk = FALSE, REPORT=1, digits = 8, plot = TRUE, parallel = "none"), model.FUN="GR4JExampleCal", model.FUN.args = list(Obs=list.obs.Cal, # mandatory Objs.names = char.objs.names, # mandatory var.names = char.obs.names, # mandatory var.units = char.obs.units, # mandatory full.period = FullCal.dates, # mandatory warmup.period = WarmUpCal.dates, cal.period = Cal.dates, # Model specific inputs InputsModel = InputsModel.Cal, # model specific RunOptions = RunOptions.Cal, # model specific area = basin.area # model specific ) )############################################################################################### # Example 1. Basic Benchmark function in minimisation ############################################################################################### # This basic Benchmark function has two objectives (M = 2) in minimisation, its Pareto optimal # front is discontinuous with four disconnected curves.This function works with 2 decision # variables (D = 2). # Main reference for function: Deb (1999) library(hydroMOPSO) lower <- c(0, 0) upper <- c(1, 1) fnBasic <- function(param){ x1 <- param[1] x2 <- param[2] obj1 <- x1 obj2 <- (1 + 10*x2)*(1-(x1/(1+10*x2))^2 - x1/(1+10*x2)*sin(2*pi*4*x1)) out <- list(c(obj1, obj2)) # For consistency with further examples, this must be a list names(out) <- "Objs" # The name "Objs" is a mandatory requirement return(out) } set.seed(100) # Setting the seed (for reproducible results) out <- hydroMOPSO(fn = fnBasic, lower = lower, upper = upper, control=list(npart = 10, maxrep = 100, maxcross = 50, MinMax = "min", maxit = 50, plot = TRUE) ) ############################################################################################### # Example 2. Basic Benchmark function in maximisation ############################################################################################### # # This example is identical to Example 1, but the functions are in maximisation # # IMPORTANT: # In the literature related to multi-objective optimisation, test functions are usually # presented with minimisation objectives (such as the function used in Example 1). However, # this does not necessarily always have to be formulated that way, especially when it comes to # real-world applications. # # In this second example we just want to remind you that the disjunctive between maximising or # minimising objectives is "a matter of signs". # # With this in account, as explained in the documentation, for hydroMOPSO operation there is # one requirement which you MUST TAKE CARE OF: # # "The problems must be formulated in such a way that ALL objectives are either maximising or # minimising. If your problem mixes both types of objectives, just add minus signs (-) in the # results that require it..." # # Main reference for function: Kursawe (1991) library(hydroMOPSO) lower <- c(0, 0) upper <- c(1, 1) fnBasic <- function(param){ x1 <- param[1] x2 <- param[2] obj1 <- -( x1 ) obj2 <- -( (1 + 10*x2)*(1-(x1/(1+10*x2))^2 - x1/(1+10*x2)*sin(2*pi*4*x1)) ) # note tha minus sign was added in obj1 and obj2 out <- list(c(obj1, obj2)) # For consistency with further examples, this must be a list names(out) <- "Objs" # The name "Objs" is a mandatory requirement return(out) } set.seed(100) # Setting the seed (for reproducible results) out <- hydroMOPSO(fn = fnBasic, lower = lower, upper = upper, control=list(npart = 10, maxrep = 100, maxcross = 50, MinMax = "max", maxit = 50, plot = TRUE) # note that now MinMax="max" ) ############################################################################################### # Example 3. Using 'smoof' package: Kursawe function ############################################################################################### # # This Benchmark function has two objectives (M = 2), its Pareto optimal front is discontinuous # and non-convex. For this example it will be implemented with 3 decision variables (D = 3) # # Main reference for function: Kursawe (1991) library(hydroMOPSO) library(smoof) D <- 3 lower <- rep(-5,D) upper <- rep(5,D) Kursawe <- smoof::makeKursaweFunction(D) # using 'smoof' package fnKursawe <- function(param){ objs <- Kursawe(x = param) obj1 <- objs[1] obj2 <- objs[2] out <- list(c(obj1, obj2)) # For consistency with further examples, this must be a list names(out) <- "Objs" # The name "Objs" is a mandatory requirement return(out) } set.seed(100) # Setting the seed (for reproducible results) out <- hydroMOPSO(fn = fnKursawe, lower = lower, upper = upper, control=list(npart = 10, maxrep = 100, maxcross = 50, MinMax = "min", maxit = 50, plot = TRUE) ) ############################################################################################### # Example 4. Using 'smoof' package: DTLZ2 function with three objectives ############################################################################################### # # In this example, this Benchmark is formulated with two objectives (M = 3) and 12 decision # variables (D = 12) its Pareto optimal front is concave. # # Main reference for function: Deb (2005) library(hydroMOPSO) library(smoof) M <- 3 D <- 12 lower <- rep(0,D) upper <- rep(1,D) DTLZ2 <- smoof::makeDTLZ2Function(D, M) # using 'smoof' package fnDTLZ2 <- function(param){ objs <- DTLZ2(x = param) obj1 <- objs[1] obj2 <- objs[2] obj3 <- objs[3] out <- list(c(obj1, obj2, obj3)) # For consistency with further examples, this must be a list names(out) <- "Objs" # The name "Objs" is a mandatory requirement return(out) } set.seed(100) # Setting the seed (for reproducible results) out <- hydroMOPSO(fn = fnDTLZ2, lower = lower, upper = upper, control=list(npart = 10, maxrep = 100, maxcross = 50, MinMax = "min", maxit = 50, plot = TRUE) ) ############################################################################################### # Example 5. Calibration of GR4J hydrological model ############################################################################################### # # For this example, a "real-world" problem has been formulated: the calibration of a # hydrological model # # In detail... # Hydrological model: GR4J (Perrin et al., 2004) # Number of parameters: four (X1, X2, X3, X4; see Perrin et al. (2004)) # Study area: Trancura River Basin (RTL) # Input variables: Precipitation (pcp) and Potetntial EvapoTranspiration (pet) # Calibration output variable: Streamflow (qobs) library(hydroMOPSO) library(airGR) library(hydroTSM) library(hydroGOF) # RTL basin ------------------------------------------------ basin.area <- 1415025887 # basin area in square meters # Load time series ----------------------------------------- data(Trancura9414001plus) # Load RTL data set # Dates ---------------------------------------------------- dates.raw <- Trancura9414001plus[,"Date"] dates <- as.Date(dates.raw) # dates # INPUTS time series --------------------------------------- # Precipitation (input variable) ts.pcp.raw <- Trancura9414001plus[,"P_mm"] ts.pcp <- zoo(ts.pcp.raw, dates) # Potential EvapoTranspiration (input variable) ts.pet.raw <- Trancura9414001plus[,"PET_mm"] ts.pet <- zoo(ts.pet.raw, dates) # OUTPUTS time series -------------------------------------- # Observed streamflow (calibration output variable) ts.qobs.raw <- Trancura9414001plus[,"Qobs_m3s"] ts.qobs <- zoo(ts.qobs.raw, dates) # Parameter ranges and noCal parameters -------------------- lower <- c("X1" = 0.01, "X2" = -100, "X3" = 0.01, "X4" = 0.5) # parameter range lower threshold upper <- c("X1" = 1200, "X3" = 100, "X3" = 5000, "X4" = 5 ) # parameter range upper threshold noCal.param <- (lower + upper)/2 # uncalibrated parameters # Names and units of observed output variables ------------- char.obs.names <- "Streamflow" char.obs.units <- "m3/s" # Objectives names ----------------------------------------- char.objs.names <- c("KGE2012_Q", "KGEGarcia_Q") # Calibration dates and subsetting ------------------------- WarmUpCal.dates <- dip("1979-01-01", "1979-12-31") # WarmUp for Calibration Cal.dates <- dip("1980-01-01", "1999-12-31") # Calibration FullCal.dates <- dip("1979-01-01", "1999-12-31") # WarmUp + Calibration start.FullCal <- FullCal.dates[1] end.FullCal <- FullCal.dates[length(FullCal.dates)] # INPUTS time series --------------------------------------- # Precipitation (input variable) ts.pcp.FullCal <- window(ts.pcp, start = start.FullCal, end = end.FullCal) # subsetting pcp # Potential EvapoTranspiration (input variable) ts.pet.FullCal <- window(ts.pet, start = start.FullCal, end = end.FullCal) # subsetting pet # OUTPUTS time series -------------------------------------- # Observed streamflow (calibration output variable) ts.qobs.FullCal <- window(ts.qobs, start = start.FullCal, end = end.FullCal) # subsetting qobs list.obs.Cal <- list(Q = ts.qobs.FullCal) # Structuring Inputs and Options of GR4J model ------------- InputsModel.Cal <- CreateInputsModel(FUN_MOD= RunModel_GR4J, DatesR= as.POSIXlt(FullCal.dates), Precip= coredata(ts.pcp.FullCal), PotEvap= coredata(ts.pet.FullCal)) RunOptions.Cal <- CreateRunOptions(FUN_MOD= RunModel_GR4J, InputsModel= InputsModel.Cal, IndPeriod_Run = 1:length(FullCal.dates), warnings = FALSE) # hydroMOPSO calibration ----------------------------------- set.seed(100) # Setting the seed (for reproducible results) Cal.results <- hydroMOPSO(fn="hydromodInR", lower=lower, upper=upper, control=list(MinMax="max", Xini.type = "lhs", npart=10, maxit=50, # for better results set maxit=250 in this case maxrep = 100, maxcross = 50, maxeval = 15000, write2disk = FALSE, REPORT=1, digits = 8, plot = TRUE, parallel = "none"), model.FUN="GR4JExampleCal", model.FUN.args = list(Obs=list.obs.Cal, # mandatory Objs.names = char.objs.names, # mandatory var.names = char.obs.names, # mandatory var.units = char.obs.units, # mandatory full.period = FullCal.dates, # mandatory warmup.period = WarmUpCal.dates, cal.period = Cal.dates, # Model specific inputs InputsModel = InputsModel.Cal, # model specific RunOptions = RunOptions.Cal, # model specific area = basin.area # model specific ) )
It takes the optimisation results of a model and reruns the simulations in a verification period. Only applicable when the results of the previous optimisation were done with fn=='hydromod' | fn=='hydromodInR'
hydroVerification(Results, fn = NULL, control = list(), model.FUN = NULL, model.FUN.args = list())hydroVerification(Results, fn = NULL, control = list(), model.FUN = NULL, model.FUN.args = list())
Results |
( |
fn |
( When |
control |
( |
model.FUN |
( |
model.FUN.args |
( |
(list)
(data.frame)
History of positions of each Pareto Front particles in all iterations. In this data.frame, the first column indicates the simulation number Sim, in ascending order from the first simulation (first iteration, phase 1) to the last simulation (last iteration, phase 2); then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters).
(data.frame)
Filled Pareto front degraded in verification period. Keep in mind that strictly speaking this is not a Pareto Front since it is reached only by extending the solutions of the original front obtained by calibration to a verification period.
(data.frame)
Perticles from filled Pareto Front. In this data.frame, the first column indicates the simulation number Sim; then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters). Note that in the objective columns the original calibration values have been replaced by those of the filled Pareto front degraded in verification period.
(list)
Time series of the model output variables in verification period, for all solutions of the filled Pareto Front obtained in calibration period. This list has as many objects as output variables, and each one corresponds to an object of class zoo with as many columns as solutions of the filled Pareto Front.
(data.frame)
Best compromise solution, i.e., the solution with the minimum Euclidean distance from the maximum values of each objective, in calibration period. data.frame with only one row and several columns: the first column indicates the simulation number Sim; then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters). Note that in the objective columns the original calibration values have been replaced by those obtained in the verification period.
(list)
Time series of the model output variables in verification period, just for the best compromise solution obtained in calibration period. This list has as many objects as output variables, and each one corresponds to an object of class zoo with a single time serie.
(list)
Solutions that minimise/maximise each of the objectives, obtained in calibration period. data.frame with only one row. In a first level, this list has as many objects as objectives involves in the optimisation, each one with a data.frame with only one row and several columns: the first column indicates the simulation number Sim; then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters). Note that in the objective columns the original calibration values have been replaced by those obtained in the verification period.
(list)
Time series of the model output variables in verification period, for the maximisation/minimisation of each objective in calibration. In a first level, this list has as many objects as objectives involves in the optimisation and, in a second level, each one corresponds to a list with as many objects as output variables, each one corresponding to an object of class zoo with a single time serie.
(character)
String indicating the analysis period, in this case "verification".
(numeric)
Number of decimal places used in dominance check. Fewer decimal places (say, 16, 8, or 4, for example) may be necessary to prevent the algorithm from resulting in solutions that are nearly the same.
(data.frame)
Name of each of the objectives (Obj1, Obj2, ...).
(data.frame)
Specification on whether the objectives are maximised or minimised, must be in c("max", "min").
(list)
Observed values of each of the variables involved in the optimisation, but now of the verification period. Keep in mind that the same format indicated as mandatory input data Obs within the FUN function is maintained.
(data.frame)
Number of objectives and number of output variables involved in the optimisation.
(data.frame)
Name and unit of measure of the output variables involved in the optimisation (var1, var1_unit, var2, var2_unit, ...).
(data.frame)
Time series indicating the warm-up period used in the optimisation.
(data.frame)
Time series indicating the calibration period used in the optimisation.
1) The intended workflow is that first you must have the results of the optimisation done with the hydroMOPSO function, which are then entered into this function (hydroVerification)
Rodrigo Marinao Rivas [email protected], Mauricio Zambrano-Bigiarini, [email protected]
hydroMOPSO
The function plot_out takes the optimization/calibration or verification
results of a hydrological model and generates the following plots:
(*): When do.png == TRUE, graphics are written to disk.
(**): Multiple graphs are generated corresponding to the targets specified
in the optimization process.
ModelOut_BCS_from_Pareto_Optimal_Front_vs_Obs: A graphical
comparison of time series for observed and simulated variables, using the
simulation of the best compromise solution.
ModelOut_from_Pareto_Optimal_Front: An uncertainty band that
encompasses the simulations given by all the solutions on the Pareto Optimal Front,
displayed in a time series. The time series of the best compromise solution is
also distinguished.
ModelOut_from_Pareto_Optimal_Front_vs_Obs: A graphical
comparison of time series for observed and simulated variables, using an
uncertainty band that encompasses the simulations given by all solutions on
the Pareto Optimal Front.
plot_out(Results, model.out = NULL, analysis.period = NULL, model.out.bcs = NULL, bcs = NULL, obs.var = NULL, dimensions = NULL, obj.names = NULL, dates.cal = NULL, dates.warmup = NULL, var.names = NULL, var.units = NULL, xlim = NULL, ylim = NULL, digits = 4, col.band = "skyblue", col.bcs = "mediumblue", col.obs = "black", lwd = 0.75, pch.bcs = 15, pch.obs = 15, main = "study case #1", drty.out = "MOPSO.out", cex.pt = 0.25, cex.main = 1, cex.lab = 1, cex.axis = 1, do.png = FALSE, legend.obs = "Observation", legend.bcs = "Best compromise solution", legend.band = "Pareto front bands")plot_out(Results, model.out = NULL, analysis.period = NULL, model.out.bcs = NULL, bcs = NULL, obs.var = NULL, dimensions = NULL, obj.names = NULL, dates.cal = NULL, dates.warmup = NULL, var.names = NULL, var.units = NULL, xlim = NULL, ylim = NULL, digits = 4, col.band = "skyblue", col.bcs = "mediumblue", col.obs = "black", lwd = 0.75, pch.bcs = 15, pch.obs = 15, main = "study case #1", drty.out = "MOPSO.out", cex.pt = 0.25, cex.main = 1, cex.lab = 1, cex.axis = 1, do.png = FALSE, legend.obs = "Observation", legend.bcs = "Best compromise solution", legend.band = "Pareto front bands")
Results |
( |
model.out |
( |
analysis.period |
( |
model.out.bcs |
( |
bcs |
( |
obs.var |
( |
dimensions |
( |
obj.names |
( |
dates.cal |
( |
dates.warmup |
( |
var.names |
( |
var.units |
( |
xlim |
( |
ylim |
( |
digits |
( |
col.band |
( |
col.bcs |
( |
col.obs |
( |
lwd |
( |
pch.bcs |
( |
pch.obs |
( |
main |
( |
drty.out |
( |
cex.pt |
( |
cex.main |
( |
cex.lab |
( |
cex.axis |
( |
do.png |
( |
legend.obs |
( |
legend.bcs |
( |
legend.band |
( |
No return value; generates plots.
Rodrigo Marinao Rivas [email protected], Mauricio Zambrano-Bigiarini, [email protected]
The function plot_param generates plots to visualize parameter
sensitivity and distribution in the context of multi-objective optimization
using hydrological models. It helps in understanding how different parameters
affect the model's performance and the trade-offs involved.
(*): When do.png == TRUE, graphics are written to disk.
plot_param(Results, legend.param = NULL, col = NULL, col.param = NULL, col.lines = NULL, name.param = NULL, lwd = 2, main = "study case #1", drty.out = "MOPSO.out", cex.pt = 1, cex.main = 1, cex.lab = 1, cex.axis = 1, cex.leg = 1, do.png = FALSE)plot_param(Results, legend.param = NULL, col = NULL, col.param = NULL, col.lines = NULL, name.param = NULL, lwd = 2, main = "study case #1", drty.out = "MOPSO.out", cex.pt = 1, cex.main = 1, cex.lab = 1, cex.axis = 1, cex.leg = 1, do.png = FALSE)
Results |
( |
legend.param |
( |
col |
( |
col.param |
( |
col.lines |
( |
name.param |
( |
lwd |
( |
main |
( |
drty.out |
( |
cex.pt |
( |
cex.main |
( |
cex.lab |
( |
cex.axis |
( |
cex.leg |
( |
do.png |
( |
No return value; generates plots as a side effect.
Rodrigo Marinao Rivas [email protected], Mauricio Zambrano-Bigiarini, [email protected]
The function plot_pof generates plots of the Pareto-optimal front (POF)
and the best compromise solution (BCS) in multi-objective optimization for
hydrological models. It visualizes trade-offs between different objectives and
helps identify the most balanced solution, assisting in model calibration and
evaluation processes.
(*): When do.png == TRUE, graphics are written to disk.
plot_pof(Results, pof = NULL, bcs = NULL, analysis.period = NULL, dimensions = NULL, maxmin = NULL, obj.thr = NULL, obj.names = NULL, main = "study case #1", drty.out = "MOPSO.out", pch.pof = 21, pch.bcs = 21, col.pof = "#f21b1b", col.bcs = "#004fcf", legend.pof = c("Pareto-optimal front solutions", "Best compromise solution"), cex.pt = 1.25, cex.main = 1, cex.lab = 1, cex.axis = 1, do.png = FALSE)plot_pof(Results, pof = NULL, bcs = NULL, analysis.period = NULL, dimensions = NULL, maxmin = NULL, obj.thr = NULL, obj.names = NULL, main = "study case #1", drty.out = "MOPSO.out", pch.pof = 21, pch.bcs = 21, col.pof = "#f21b1b", col.bcs = "#004fcf", legend.pof = c("Pareto-optimal front solutions", "Best compromise solution"), cex.pt = 1.25, cex.main = 1, cex.lab = 1, cex.axis = 1, do.png = FALSE)
Results |
( |
pof |
( |
bcs |
( |
analysis.period |
( |
dimensions |
( |
maxmin |
( |
obj.thr |
( |
obj.names |
( |
main |
( |
drty.out |
( |
pch.pof |
( |
pch.bcs |
( |
col.pof |
( |
col.bcs |
( |
legend.pof |
( |
cex.pt |
( |
cex.main |
( |
cex.lab |
( |
cex.axis |
( |
do.png |
( |
No return value; generates plots as a side effect.
Rodrigo Marinao Rivas [email protected], Mauricio Zambrano-Bigiarini, [email protected]
The function plot_results consolidates the plotting capabilities for
hydrological model outputs, Pareto-optimal front solutions, and parameter
sensitivity analyses. It calls three subordinate functions (plot_out,
plot_pof, plot_param) to generate the required plots, offering
a comprehensive visualization tool for model evaluation and optimization results.
(*): When do.png == TRUE, graphics are written to disk.
plot_results(Results, model.out = NULL, analysis.period = NULL, model.out.bcs = NULL, bcs = NULL, obs.var = NULL, dimensions = NULL, obj.names = NULL, dates.cal = NULL, dates.warmup = NULL, var.names = NULL, var.units = NULL, xlim = NULL, ylim = NULL, digits = 4, col.band = "skyblue", col.bcs = "mediumblue", col.obs = "black", lwd = 0.75, pch.bcs = 15, pch.obs = 15, main = "study case #1", drty.out = "MOPSO.out", cex.pt.out = 0.25, cex.pt.pof = 1.25, cex.pt.param = 1, cex.main = 1, cex.lab = 1, cex.axis = 1, do.png = FALSE, legend.obs = "Observation", legend.bcs = "Best compromise solution", legend.band = "Pareto front bands", pof = NULL, maxmin = NULL, obj.thr = NULL, pch.pof = 21, col.pof = "#f21b1b", legend.pof = c("Pareto-optimal front solutions", "Best compromise solution"), legend.param = NULL, col = NULL, col.param = NULL, col.lines = NULL, name.param = NULL, cex.leg = 1)plot_results(Results, model.out = NULL, analysis.period = NULL, model.out.bcs = NULL, bcs = NULL, obs.var = NULL, dimensions = NULL, obj.names = NULL, dates.cal = NULL, dates.warmup = NULL, var.names = NULL, var.units = NULL, xlim = NULL, ylim = NULL, digits = 4, col.band = "skyblue", col.bcs = "mediumblue", col.obs = "black", lwd = 0.75, pch.bcs = 15, pch.obs = 15, main = "study case #1", drty.out = "MOPSO.out", cex.pt.out = 0.25, cex.pt.pof = 1.25, cex.pt.param = 1, cex.main = 1, cex.lab = 1, cex.axis = 1, do.png = FALSE, legend.obs = "Observation", legend.bcs = "Best compromise solution", legend.band = "Pareto front bands", pof = NULL, maxmin = NULL, obj.thr = NULL, pch.pof = 21, col.pof = "#f21b1b", legend.pof = c("Pareto-optimal front solutions", "Best compromise solution"), legend.param = NULL, col = NULL, col.param = NULL, col.lines = NULL, name.param = NULL, cex.leg = 1)
Results |
( |
model.out |
( |
analysis.period |
( |
model.out.bcs |
( |
bcs |
( |
obs.var |
( |
dimensions |
( |
obj.names |
( |
dates.cal |
( |
dates.warmup |
( |
var.names |
( |
var.units |
( |
xlim |
( |
ylim |
( |
digits |
( |
col.band |
( |
col.bcs |
( |
col.obs |
( |
lwd |
( |
pch.bcs |
( |
pch.obs |
( |
main |
( |
drty.out |
( |
cex.pt.out |
( |
cex.pt.pof |
( |
cex.pt.param |
( |
cex.main |
( |
cex.lab |
( |
cex.axis |
( |
do.png |
( |
legend.obs |
( |
legend.bcs |
( |
legend.band |
( |
pof |
( |
maxmin |
( |
obj.thr |
( |
pch.pof |
( |
col.pof |
( |
legend.pof |
( |
legend.param |
( |
col |
( |
col.param |
( |
col.lines |
( |
name.param |
( |
cex.leg |
( |
No return value; generates plots as a side effect.
Rodrigo Marinao Rivas [email protected], Mauricio Zambrano-Bigiarini, [email protected]
plot_out, plot_pof, plot_param
Read results saved on disk from an optimization with hydroMOPSO. This feature only applies when fn is in c("hydromod", "hydromodInR")
read_results(fn = NULL, control = list(), model.FUN = NULL, model.FUN.args = list() )read_results(fn = NULL, control = list(), model.FUN = NULL, model.FUN.args = list() )
fn |
( When |
control |
( |
model.FUN |
( |
model.FUN.args |
( |
The control argument is a list that can supply any of the following components:
(character)
(OPTIONAL) Used only when fn='hydromod'
Name of the directory storing the input files required for PSO, i.e. ‘ParamRanges.txt’ and ‘ParamFiles.txt’.
(character)
Path to the directory storing the output files generated by hydroMOPSO.
(numeric)
(OPTIONAL) Used only when write2disk=TRUE
Number of significant digits used for writing the output files with scientific notation.
(numeric)
Number of decimal places used in dominance check. Fewer decimal places (say, 16, 8, or 4, for example) may be necessary to prevent the algorithm from resulting in solutions that are nearly the same.
By default digits.dom=Inf, which basically means numbers are not rounded
(logical)
Indicates if the output files will be written to the disk.
By default write2disk=TRUE
(logical)
Indicates if progress messages are to be printed.
By default verbose=TRUE
(integer)
(OPTIONAL) Used only when verbose=TRUE
The frequency of report messages printed to the screen.
By default REPORT=10
(character)
Indicates how to parallelise ‘hydroMOPSO’ (to be precise, only the evaluation of the objective function fn is parallelised). Valid values are:
-)none: no parallelisation is made (this is the default value)
-)parallel: parallel computations for network clusters or machines with multiple cores or CPUs. A ‘FORK’ cluster is created with the makeForkCluster function. When fn.name='hydromod' the evaluation of the objective function fn is done with the clusterApply function of the parallel package. When fn.name != 'hydromod' the evaluation of the objective function fn is done with the parRapply function of the parallel package.
-)parallelWin: parallel computations for network clusters or machines with multiple cores or CPUs (this is the only parallel implementation that works on Windows machines). A ‘PSOCK’ cluster is created with the makeCluster function. When fn.name='hydromod' the evaluation of the objective function fn is done with the clusterApply function of the parallel package. When fn.name != 'hydromod' the evaluation of the objective function fn is done with the parRapply function of the parallel package.
(numeric)
(OPTIONAL) Used only when parallel!='none'
Indicates the number of cores/CPUs to be used in the local multi-core machine, or the number of nodes to be used in the network cluster.
By default par.nnodes is set to the amount of cores detected by the function detectCores() (parallel package)
(character)
(OPTIONAL) Used only when parallel='parallelWin'
List of package names (as characters) that need to be loaded on each node for allowing the objective function fn to be evaluated.
(list)
(list)
Particle repository history of all iterations (both phases of NMPSO), detailing:
- ParetoFront (data.frame)
History of objectives values of each Pareto Front particles in all iterations (both phases). In this data.frame, the first column indicates the iteration Iter; the second column the phase Phase (1 or 2); and the following columns are as many as objectives treated, being identified with the assigned name.
- Particles_ParetoFront (data.frame)
History of positions of each Pareto Front particles in all iterations (both phases). In this data.frame, the first column indicates the iteration Iter; the second column the phase Phase (1 or 2); then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters).
- MaxMin (data.frame)
Specification on whether the objectives are maximised or minimised.
- ObjsNames (data.frame)
Name of each of the objectives (Obj1, Obj2, ...).
(list)
(ONLY ADDED WHEN fn=='hydromod' | fn=='hydromodInR')
Details about the modeling involved in optimisation:
- Dimensions (data.frame)
Number of objectives and number of output variables involved in the optimisation.
- NamesAndUnitsVars (data.frame)
Name and unit of measure of the output variables involved in the optimisation (var1, var1_unit, var2, var2_unit, ...).
- Obs (list)
Observed values of each of the variables involved in the optimisation, keeping in mind that the same format indicated as mandatory input data Obs within the FUN function is maintained.
- WarmUp (data.frame)
Time series indicating the warm-up period used in the optimisation.
- DatesCal (data.frame)
Time series indicating the calibration period used in the optimisation.
(list)
(ONLY ADDED WHEN fn=='hydromod' | fn=='hydromodInR')
Post-processed results about the modeling involved in optimisation:
- ParticlesFull (data.frame)
History of positions of each Pareto Front particles in all iterations. In this data.frame, the first column indicates the simulation number Sim, in ascending order from the first simulation (first iteration, phase 1) to the last simulation (last iteration, phase 2); then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters).
- FilledPOF (data.frame)
Filled Pareto front, built from evaluating the dominance of the solutions of all the iterations performed in the optimisation. To prevent the filled Pareto Front from having too many solutions, the parameters and objective values are rounded according to input DigitsDom (number of decimal places). In this data.frame, the first column indicates the simulation number Sim; then as many columns as objectives treated, being identified with the assigned name.
- ParticlesFilledPOF (data.frame)
Perticles from filled Pareto Front. In this data.frame, the first column indicates the simulation number Sim; then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters).
- ModelOut (list)
Time series of the model output variables, for all solutions of the filled Pareto Front. This list has as many objects as output variables, and each one corresponds to an object of class zoo with as many columns as solutions of the filled Pareto Front.
- ParticleBestCS (data.frame)
Best compromise solution, i.e., the solution with the minimum Euclidean distance from the maximum values of each objective. data.frame with only one row and several columns: the first column indicates the simulation number Sim; then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters).
- ModelOutBestCS (list)
Time series of the model output variables, just for the best compromise solution. This list has as many objects as output variables, and each one corresponds to an object of class zoo with a single time serie.
- ParticleBestObjs (list)
Solutions that minimise/maximise each of the objectives. data.frame with only one row. In a first level, this list has as many objects as objectives involves in the optimisation, each one with a data.frame with only one row and several columns: the first column indicates the simulation number Sim; then as many columns as objectives treated, being identified with the assigned name; and finally, as many columns as decision variables (parameters).
- ModelOutBestObjs (list)
Time series of the model output variables, for the maximisation/minimisation of each objective. In a first level, this list has as many objects as objectives involves in the optimisation and, in a second level, each one corresponds to a list with as many objects as output variables, each one corresponding to an object of class zoo with a single time serie.
- AnalysisPeriod (character)
String indicating the analysis period, in this case "calibration".
- DigitsDom (numeric)
Number of decimal places used in dominance check. Fewer decimal places (say, 16, 8, or 4, for example) may be necessary to prevent the algorithm from resulting in solutions that are nearly the same.
- ObjsNames (data.frame)
Name of each of the objectives (Obj1, Obj2, ...).
- MaxMin (data.frame)
Specification on whether the objectives are maximised or minimised, must be in c("max", "min").
- Obs (list)
Observed values of each of the variables involved in the optimisation, keeping in mind that the same format indicated as mandatory input data Obs within the FUN function is maintained.
- Dimensions (data.frame)
Number of objectives and number of output variables involved in the optimisation.
- NamesAndUnitsVars (data.frame)
Name and unit of measure of the output variables involved in the optimisation (var1, var1_unit, var2, var2_unit, ...).
- WarmUp (data.frame)
Time series indicating the warm-up period used in the optimisation.
- DatesCal (data.frame)
Time series indicating the calibration period used in the optimisation.
1) The intended workflow is that first you must have the results of the optimisation done with the hydroMOPSO function, having saved the results to disk (write2disk=TRUE in hydroMOPSO)
2) Based on the previous point, the user must ensure that the input arguments fn, control, model.FUN and model.FUN.args that are entered in the hydroMOPSO and read_results functions must be EXACTLY THE SAME
Rodrigo Marinao Rivas [email protected], Mauricio Zambrano-Bigiarini, [email protected]
hydroMOPSO
Simple comparison between time series of observed and simulated variables. This function is specially designed to check the correct operation of the wrapper functions prepared by the user. The premise is as follows: if the user can generate a 'nice' graph (graphically evidencing the simulated and observed values, and obtaining finite numerical values for the objectives) then they can proceed with greater confidence to the hydroMOPSO optimisation step.
SimVsObs(sim, obs, obj.values, obj.names, var.names, var.units, legend.sim = "Simulated", legend.obs = "Observed", cal.period, warmup.period, full.period, xlim = NULL, ylim = NULL, main = "study case #1", analysis.period, digits.round = 8, col.obs = "black", col.sim = "mediumblue", lwd = 0.75, pch.obs = 15, cex.pt = 0.25, cex.main = 1, cex.lab = 1, cex.axis = 1, cex.leg = 1)SimVsObs(sim, obs, obj.values, obj.names, var.names, var.units, legend.sim = "Simulated", legend.obs = "Observed", cal.period, warmup.period, full.period, xlim = NULL, ylim = NULL, main = "study case #1", analysis.period, digits.round = 8, col.obs = "black", col.sim = "mediumblue", lwd = 0.75, pch.obs = 15, cex.pt = 0.25, cex.main = 1, cex.lab = 1, cex.axis = 1, cex.leg = 1)
sim |
( |
obs |
( |
obj.values |
( |
obj.names |
( |
var.names |
( |
var.units |
( |
legend.sim |
( |
legend.obs |
( |
warmup.period |
( |
cal.period |
( |
full.period |
( |
xlim |
( |
ylim |
( |
main |
( |
analysis.period |
( |
digits.round |
( |
col.obs |
( |
col.sim |
( |
lwd |
( |
pch.obs |
( |
cex.pt |
( |
cex.main |
( |
cex.lab |
( |
cex.axis |
( |
cex.leg |
( |
No return value
Rodrigo Marinao Rivas [email protected], Mauricio Zambrano-Bigiarini, [email protected]
hydroMOPSO
############################################################################################### # This example is derived from example 5 of the hydroMOPSO function library(hydroMOPSO) library(airGR) library(hydroTSM) library(hydroGOF) # RTL basin ------------------------------------------------ basin.area <- 1415025887 # basin area in square meters # Load time series ----------------------------------------- data(Trancura9414001plus) # Load RTL data set # Dates ---------------------------------------------------- dates.raw <- Trancura9414001plus[,"Date"] dates <- as.Date(dates.raw) # dates # INPUTS time series --------------------------------------- # Precipitation (input variable) ts.pcp.raw <- Trancura9414001plus[,"P_mm"] ts.pcp <- zoo(ts.pcp.raw, dates) # Potential EvapoTranspiration (input variable) ts.pet.raw <- Trancura9414001plus[,"PET_mm"] ts.pet <- zoo(ts.pet.raw, dates) # OUTPUTS time series -------------------------------------- # Observed streamflow (calibration output variable) ts.qobs.raw <- Trancura9414001plus[,"Qobs_m3s"] ts.qobs <- zoo(ts.qobs.raw, dates) # Parameter ranges and noCal parameters -------------------- lower <- c("X1" = 0.01, "X2" = -100, "X3" = 0.01, "X4" = 0.5) # parameter range lower threshold upper <- c("X1" = 1200, "X3" = 100, "X3" = 5000, "X4" = 5 ) # parameter range upper threshold noCal.param <- (lower + upper)/2 # uncalibrated parameters # Names and units of observed output variables ------------- char.obs.names <- "Streamflow" char.obs.units <- "m3/s" # Objectives names ----------------------------------------- char.objs.names <- c("KGE2012_Q", "KGEGarcia_Q") # Calibration dates and subsetting ------------------------- WarmUpCal.dates <- dip("1979-01-01", "1979-12-31") # WarmUp for Calibration Cal.dates <- dip("1980-01-01", "1999-12-31") # Calibration FullCal.dates <- dip("1979-01-01", "1999-12-31") # WarmUp + Calibration start.FullCal <- FullCal.dates[1] end.FullCal <- FullCal.dates[length(FullCal.dates)] # INPUTS time series --------------------------------------- # Precipitation (input variable) ts.pcp.FullCal <- window(ts.pcp, start = start.FullCal, end = end.FullCal) # subsetting pcp # Potential EvapoTranspiration (input variable) ts.pet.FullCal <- window(ts.pet, start = start.FullCal, end = end.FullCal) # subsetting pet # OUTPUTS time series -------------------------------------- # Observed streamflow (calibration output variable) ts.qobs.FullCal <- window(ts.qobs, start = start.FullCal, end = end.FullCal) # subsetting qobs list.obs.Cal <- list(Q = ts.qobs.FullCal) # Structuring Inputs and Options of GR4J model ------------- InputsModel.Cal <- CreateInputsModel(FUN_MOD= RunModel_GR4J, DatesR= as.POSIXlt(FullCal.dates), Precip= coredata(ts.pcp.FullCal), PotEvap= coredata(ts.pet.FullCal)) RunOptions.Cal <- CreateRunOptions(FUN_MOD= RunModel_GR4J, InputsModel= InputsModel.Cal, IndPeriod_Run = 1:length(FullCal.dates), warnings = FALSE) # Checking Wrapper function in calibration ----------------- noCal.results.Cal <- GR4JExampleCal(param.values = noCal.param, Obs = list.obs.Cal, Objs.names = char.objs.names, var.names = char.obs.names, var.units = char.obs.units, warmup.period = WarmUpCal.dates, cal.period = Cal.dates, full.period = FullCal.dates, InputsModel = InputsModel.Cal, RunOptions = RunOptions.Cal, area = basin.area) noCal.sim.Cal <- noCal.results.Cal[["sim"]] noCal.objs.Cal <- noCal.results.Cal[["Objs"]] dev.new() SimVsObs(sim = noCal.sim.Cal, obs = list.obs.Cal, obj.values = noCal.objs.Cal, obj.names = char.objs.names, var.names = char.obs.names, var.units = char.obs.units, legend.sim = "Simulated", legend.obs = "Observed", warmup.period = WarmUpCal.dates, cal.period = Cal.dates, full.period = FullCal.dates, main = "...just checking GR4JExampleCal function", analysis.period = "calibration", digits.round = 4)############################################################################################### # This example is derived from example 5 of the hydroMOPSO function library(hydroMOPSO) library(airGR) library(hydroTSM) library(hydroGOF) # RTL basin ------------------------------------------------ basin.area <- 1415025887 # basin area in square meters # Load time series ----------------------------------------- data(Trancura9414001plus) # Load RTL data set # Dates ---------------------------------------------------- dates.raw <- Trancura9414001plus[,"Date"] dates <- as.Date(dates.raw) # dates # INPUTS time series --------------------------------------- # Precipitation (input variable) ts.pcp.raw <- Trancura9414001plus[,"P_mm"] ts.pcp <- zoo(ts.pcp.raw, dates) # Potential EvapoTranspiration (input variable) ts.pet.raw <- Trancura9414001plus[,"PET_mm"] ts.pet <- zoo(ts.pet.raw, dates) # OUTPUTS time series -------------------------------------- # Observed streamflow (calibration output variable) ts.qobs.raw <- Trancura9414001plus[,"Qobs_m3s"] ts.qobs <- zoo(ts.qobs.raw, dates) # Parameter ranges and noCal parameters -------------------- lower <- c("X1" = 0.01, "X2" = -100, "X3" = 0.01, "X4" = 0.5) # parameter range lower threshold upper <- c("X1" = 1200, "X3" = 100, "X3" = 5000, "X4" = 5 ) # parameter range upper threshold noCal.param <- (lower + upper)/2 # uncalibrated parameters # Names and units of observed output variables ------------- char.obs.names <- "Streamflow" char.obs.units <- "m3/s" # Objectives names ----------------------------------------- char.objs.names <- c("KGE2012_Q", "KGEGarcia_Q") # Calibration dates and subsetting ------------------------- WarmUpCal.dates <- dip("1979-01-01", "1979-12-31") # WarmUp for Calibration Cal.dates <- dip("1980-01-01", "1999-12-31") # Calibration FullCal.dates <- dip("1979-01-01", "1999-12-31") # WarmUp + Calibration start.FullCal <- FullCal.dates[1] end.FullCal <- FullCal.dates[length(FullCal.dates)] # INPUTS time series --------------------------------------- # Precipitation (input variable) ts.pcp.FullCal <- window(ts.pcp, start = start.FullCal, end = end.FullCal) # subsetting pcp # Potential EvapoTranspiration (input variable) ts.pet.FullCal <- window(ts.pet, start = start.FullCal, end = end.FullCal) # subsetting pet # OUTPUTS time series -------------------------------------- # Observed streamflow (calibration output variable) ts.qobs.FullCal <- window(ts.qobs, start = start.FullCal, end = end.FullCal) # subsetting qobs list.obs.Cal <- list(Q = ts.qobs.FullCal) # Structuring Inputs and Options of GR4J model ------------- InputsModel.Cal <- CreateInputsModel(FUN_MOD= RunModel_GR4J, DatesR= as.POSIXlt(FullCal.dates), Precip= coredata(ts.pcp.FullCal), PotEvap= coredata(ts.pet.FullCal)) RunOptions.Cal <- CreateRunOptions(FUN_MOD= RunModel_GR4J, InputsModel= InputsModel.Cal, IndPeriod_Run = 1:length(FullCal.dates), warnings = FALSE) # Checking Wrapper function in calibration ----------------- noCal.results.Cal <- GR4JExampleCal(param.values = noCal.param, Obs = list.obs.Cal, Objs.names = char.objs.names, var.names = char.obs.names, var.units = char.obs.units, warmup.period = WarmUpCal.dates, cal.period = Cal.dates, full.period = FullCal.dates, InputsModel = InputsModel.Cal, RunOptions = RunOptions.Cal, area = basin.area) noCal.sim.Cal <- noCal.results.Cal[["sim"]] noCal.objs.Cal <- noCal.results.Cal[["Objs"]] dev.new() SimVsObs(sim = noCal.sim.Cal, obs = list.obs.Cal, obj.values = noCal.objs.Cal, obj.names = char.objs.names, var.names = char.obs.names, var.units = char.obs.units, legend.sim = "Simulated", legend.obs = "Observed", warmup.period = WarmUpCal.dates, cal.period = Cal.dates, full.period = FullCal.dates, main = "...just checking GR4JExampleCal function", analysis.period = "calibration", digits.round = 4)
This function provides the capability to modify input text files directly within the R environment, requering only minimal instructions. It was conceived to facilitate users to execute the calibration procedure via hydroMOPSO(), while staying entirely within the R environment. Thus, it precludes the need for manually editing text files, eliminating undesirable coordination that could potentially lead to errors.
SpecificValueInFile(modlist)SpecificValueInFile(modlist)
modlist |
( |
The modlist argument is a list with an indeterminate number of objects, which only depends on the number of modifications the user needs to make, for example, being something like modlist=list(mod_1, mod_2, mod_3,mod_4). Each of the ‘mod’ objects in this list must provide the following items:
(character)
The ID of the parameter to be modified.
(numeric)
Numeric value to be written into the text file.
(character)
Name of the text file that will be modified.
(numeric)
Row number in filename where newvalue will be written.
(numeric)
Starting column number in filename where newvalue is going to be written.
(numeric)
Ending column number in filename where newvalue is going to be written.
(numeric)
Number of decimal places used to write newvalue into filename.
No return value
Rodrigo Marinao Rivas [email protected], Mauricio Zambrano-Bigiarini, [email protected]
Daily time series of precipitation, air temperature (max, min, mean), potential evapotranspiration and streamflows for the catchment draining into the 'Trancura antes de Llafenco' streamflow station (Cod.BNA: 9414001, drainage area= 1416 km2), Araucania Region, Chile (Lat:-39.3333, Lon:-71.6667), with data from 01/Jan/1979 to 31/Dec/2020 (including some gaps in streamflow data).
data(Trancura9414001plus)data(Trancura9414001plus)
zoo with seven columns:
-) Dates: character with the date (YYYY-MM-DD) for each daily observation.
-) Pp_mm: Spatially-averaged mean daily values of precipitation computed based on the CR2met dataset, [mm/day].
-) Tmax_degC: Spatially-averaged mean daily values of maximum air temperature computed based on the CR2met dataset, [degree Celsius].
-) Tmin_degC: Spatially-averaged mean daily values of minimum air temperature computed based on the CR2met dataset, [degree Celsius].
-) Tmean_degC: Spatially-averaged mean daily values of mean air temperature computed based on the CR2met dataset, [degree Celsius].
-) PET_mm: Spatially-averaged mean daily values of potential evapotranspiration (PET), computed with the Hargreaves-Samani equation based on daily maximum and minimum air temperatures obtained from the CR2met dataset, [mm/day].
-) Qobs_m3s: Daily streamflows measured at the Trancura antes de Llafenco (9414001) station.
-) ETobs_mm: Daily evapotranspiration (ET) estimated at the Trancura antes de Llafenco (9414001) with the 8-day evapotranspiration product PML v2 (Zhang, 2019). The 8-day time series are disaggregated on a daily scale just dividing by 8, so, it is recommended to use this information on a weekly, monthly or annual scale.
CR2met v2 is a gridded product of observed daily precipitation an maximum/minimim temperature, covering the period 1979-01-01 to 2020-12-31. Its developed by Boisier et al. (2018) and provided by Center for Climate and Resilience Research, Universidad de Chile, Santiago, Chile (https://zenodo.org/records/7529682, last accessed [Dic 2023]).
PML v2 is a gridded product of estimated 8-day evapotranspiration, covering the period 2020-03-01 to 2020-04-30. The proper use of this information as "observed values" can be a subject of discussion, however, they are included in hydroMOPSO for mere didactic purposes, hoping that future research will provide more reliable information to use as ET observations.
These data are intended to be used for research purposes only, being distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.
Boisier, J. P., Alvarez-Garreton, C., Cepeda, J., Osses, A., Vasquez, N., and Rondanelli, R. (2018). CR2MET: A high-resolution precipitation and temperature dataset for hydroclimatic research in Chile. EGUGA, 20, 19739. Opgehaal van https://ui.adsabs.harvard.edu/abs/2018EGUGA..2019739B/abstract
Zhang, Y., Kong, D., Gan, R., Chiew, F. H. S., McVicar, T. R., Zhang, Q., & Yang, Y. (2019). Coupled estimation of 500 m and 8-day resolution global evapotranspiration and gross primary production in 2002-2017. Remote Sensing of Environment, 222, 165-182. doi:10.1016/J.RSE.2018.12.031