https://github.com/cran/simecol
Tip revision: 4b48146d673fc6f67dbc8258d6d4afa017bae337 authored by Thomas Petzoldt on 28 November 2008, 00:00:00 UTC
version 0.6-4
version 0.6-4
Tip revision: 4b48146
sim.R
setGeneric("sim", function(obj, initialize = TRUE, ...) standardGeneric("sim"))
setMethod("sim", "simObj",
function(obj, initialize = TRUE, ...) {
if (initialize & !is.null(obj@initfunc)) obj <- initialize(obj)
out <- do.call(obj@solver, list(obj, ...))
obj@out <- out
invisible(obj)
}
)
setMethod("sim", "odeModel",
function(obj, initialize = TRUE, ...) {
if (initialize & !is.null(obj@initfunc)) obj <- initialize(obj)
times <- fromtoby(obj@times)
func <- obj@main
inputs <- obj@inputs
equations <- obj@equations
environment(func) <- environment()
equations <- addtoenv(equations)
out <- do.call(obj@solver, list(obj@init, times, func, obj@parms, ...))
obj@out <- out
invisible(obj)
}
)
setMethod("sim", "gridModel",
function(obj, initialize = TRUE, ...) {
if (initialize & !is.null(obj@initfunc)) obj <- initialize(obj)
times <- fromtoby(obj@times)
out <- do.call(obj@solver, list(obj, ...))
obj@out <- out
invisible(obj)
}
)