sdBuildCoupledScenario: Builds a Coupled Scenario

Description Usage Arguments Value Examples

Description

Merge a named list of sdScenarioClass objects in to a unique coupled scenario object with all the variables named with the prefix 'ModelId.' followed by the original variable name. The 'ModelId' is the name of each element in the scenarios list and must be the same name of the component ID that will use it. Use the arguments to define the coupled scenario simulation time sequence (the arguments from, to and by must be present to define the time sequence) and the integrator method to be used in the simulations (or the default 'lsoda' will be used).

Usage

1
2
3
4
5
sdBuildCoupledScenario(coupledScenarioId = NULL, scenarios = NULL,
  from = NULL, to = NULL, by = NULL, method = c("lsoda", "lsode",
  "lsodes", "lsodar", "vode", "daspk", "euler", "rk4", "ode23", "ode45",
  "radau", "bdf", "bdf_d", "adams", "impAdams", "impAdams_d"),
  timeSeriesDirectory = "", varNames = FALSE)

Arguments

coupledScenarioId

A string with the coupled scenario ID. If missing a default timestamp ID will be created.

scenarios

A named list of not empty sdScenarioClass objects and/or character strings with a sdScenario XML or EXCEL file name.

When passing a scenario in a EXCEL file it should follow the default format described in the sdLoadScenario documentation. All the scenario elements of this list must be named with the model ID that will use it.

from

The starting value of the time sequence. Numeric of length 1.

to

The end (maximal) value of the time sequence. Numeric of length 1.

by

number: increment of the time sequence.

method

The integrator to be used in the simulation, a string ("lsoda", "lsode", "lsodes","lsodar","vode", "daspk", "euler", "rk4", "ode23", "ode45", "radau", "bdf", "bdf_d", "adams", "impAdams" or "impAdams_d"). Default value is "lsoda".

When running with support to events the given method must be one of the following routines, which have root-finding capability: lsoda, lsode or radau; If the given method is different from any of these three routines the simulator will run with the default method "lsoda".

See the ode and the events details section for more information.

timeSeriesDirectory

The directory where time series inputs are stored (when passing the time series inputs via external text files).

varNames

logical: if TRUE the return value is a list with two elements - the coupledScenario containing the built coupled scenario object and the varNames containing a list of all the scenarios variables names; if FALSE the return value is just the coupled scenario object, the default.

Value

Either the coupled scenario object with all variables named with the prefix 'ModelId.' followed by the original variable name or, if varNames is TRUE, a list with two elements - the coupledScenario containing the built coupled scenario object and the varNames containing a list of all the scenarios variables names.

Examples

 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
36
37
38
39
## Let's build a coupled scenario for the Lotka-Volterra example model 
# presented in the help('sdCoupledModel')

# create the Prey model variables and scenario
stPrey <- list(P = 1)
parsPrey      <- list(rG = 1.0,      
                      K  = 10)
inpPrey <- list(IngestC = 0)

preyScen <- sdScenario(scenarioId = "preyScen",
                       state = stPrey,
                       parameter = parsPrey,
                       input = inpPrey)
                       
# create the Consumer model variables and scenario
stConsumer <- list(C = 2)
parsConsumer  <- list(rI = 0.2,
                      rM = 0.2 ,   
                      AE = 0.5) 
inpConsumer <- list(P = 0)

consumerScen <- sdScenario(scenarioId = "consumerScen",
                           state = stConsumer,
                           parameter = parsConsumer,
                           input = inpConsumer)
                           
## Create the coupled scenario and print it
coupledLvScen <- sdBuildCoupledScenario(
  coupledScenarioId = "LVcoupled",
  scenarios = c(Prey = preyScen, 
                Consumer = consumerScen), 
  method = "lsoda",
  from = 0,
  to = 200,
  by = 1) 
print(coupledLvScen)  
## this scenario can be used to simulate the coupled Lotka-Volterra Model
# in a different environment by setting different values for the variables 
# and passing it via the argument 'scenario' to the sdSimulate function           

EmbrapaInformaticaAgropecuaria/sdsim documentation built on May 10, 2019, 9:58 a.m.