Description Usage Arguments Value Note Examples
View source: R/tradeoff_batch.R
Function to drive large numbers of iteration of trademod
1 | tradeoff_batch(parms, input_key = "ZA", todisk = TRUE, silent = FALSE)
|
parms |
Matrix or data.frame providing input parameters permutations |
input_key |
Two letter location code indicating input data to load. |
todisk |
TRUE, in which case output data.table is written to disk |
silent |
Silent or verbose model. TRUE (default) or FALSE |
List of tradeoff_mod impact data.frames and conversion data.table if todisk is FALSE
This is one place where parallelizing could be useful, replacing for loop with foreach.
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 | # Define parameter sets
# Constraint space
cnames <- c("Ag", "C", "bd", "cost")
cblist <- list(cb1 <- c(1, 0, 0, 0),
cb2 <- c(1, 1, 0, 0),
cb3 <- c(1, 1, 1, 0),
cb1r <- c(1, 0, 0, 1),
cb2r <- c(1, 1, 0, 1),
cb3r <- c(1, 1, 1, 1))
# ymod space
yblist <- list(yb1 <- c(1, 1),
yb2 <- c(0.8, 1),
yb3 <- c(1.2, 1))
# prod_targ space
tnames <- c("maize", "cassava", "ground", "cotton", "soy", "pulse",
"sunflower", "sugarcane", "wheat")
targlist <- list(targ1 <- rep(2, length(tnames)),
targ2 <- rep(3, length(tnames)),
targ3 <- rep(4, length(tnames)))
parms <- do.call(rbind, lapply(yblist, function(x) {
do.call(rbind, lapply(targlist, function(y) {
do.call(rbind, lapply(cblist, function(z) {
v <- c(z, x, y)
names(v) <- c(cnames, "y1", "y2", tnames)
v
}))
}))
}))
parms <- parms[1:5, ]
batch_test <- tradeoff_batch(parms = parms, input_key = "ZA", todisk = FALSE,
silent = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.