Description Usage Arguments Value Note See Also Examples
Simulation of a mjpModel object
1 2 3 | ## S4 method for signature 'mjpModel'
sim(obj, initialize = FALSE, seed = 1,
njump = 1e+06, outSlot = TRUE, ...)
|
obj |
object of class |
initialize |
boolean variable. If initialize = TRUE and |
seed |
an integer or NULL. This makes the result of |
njump |
number of maximal possible jumps. The default value is 1e+06
and should be sufficient. If the simulation breaks before the end of
simulation time, try to set a higher value for |
outSlot |
boolean variable. If FALSE, only the result of the simulation
is returned. If TRUE, the whole |
... |
optional parameters passed to the solver function. |
The returned value depends on the parameter outSlot
.
If outSlot = TRUE
, the function returns the complete pdmpModel
instance with the simulation result saved in the out
slot.
Otherwise, only the simulation result is returned.
If the result is stored in slot out
, it can get lost if the
value of the other slots is changed via <-.
See mjp-accessors
for further informations.
function multSim
or multSimCsv
for multiple simulations, ... for plot and summary methods of the simulation.
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 | data("KendallBD") # load object of class pdmpModel
#### simulations
# simulate and plot the result
plot(sim(KendallBD, seed = 1))
# simulate and plot the result with random seed
plot(sim(KendallBD, seed = NULL))
# simulating again with seed = 1 leads to the same result as before
plot(sim(KendallBD, seed = 1))
#### be careful about slot out!
out(KendallBD) # NULL, because results have not been stored
simBD <- sim(kendallBD) # simulation results are stored in out
head(out(simBD))
init(KendallBD) <- c(N = 10)
head(out(KendallBD)) # NULL, because slot init has changed
simBD <- sim(KendallBD, outSlot = FALSE)
str(simBD) # only the simulation result, the mjpModel object is lost
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.