-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocumentation_example.rmd
35 lines (24 loc) · 1005 Bytes
/
documentation_example.rmd
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
```{r setup, message=FALSE}
# packages
library(tidyverse)
library(rvle)
library(rsunflo)
```
# Simulation
```{r simulation}
# load design of experiments
design <- readRDS("inst/doc/files/design.rds")
# load the sunflo model
sunflo <- new("Rvle", file = "sunflo_web.vpz", pkg = "sunflo")
run_sunflo <- function(id){design %>% play(unit=id) %>% shape(view="timed")}
# run the model with default parameterization
sunflo %>% run() %>% results() %>% shape(view="timed") %>% display()
# run the model with parameters defined in the design of experiments
design %>% play(unit=1) %>% shape(view="timed") %>% display()
# multi-simulation (4 core i7 : 71 ms/sim), for larger design, parallelization is possible with the *doMC* package
list_simulation <- design %>% select(id)
output <- list_simulation %>%
plyr::mdply(possibly(run_sunflo, NULL)) %>% as_tibble()
# compute crop performance indicator (one experiment -> one vector)
output_indicators <- output %>% group_by(id) %>% do(indicate(.))
```