https://github.com/cran/simecol
Tip revision: 75f01f442f9263d2cd5b3c69bbec81add7b93c47 authored by Thomas Petzoldt on 10 February 2009, 00:00:00 UTC
version 0.6-5
version 0.6-5
Tip revision: 75f01f4
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)
}
)