StepEulerSPN: Create a function for advancing the state of an SPN by using...
This function creates a function for advancing the state of an SPN model using a simple continuous deterministic Euler integration method. The resulting function (closure) can be used in conjunction with other functions (such as
simTs) for simulating realisations of SPN models.
An R list with named components representing a stochastic
Petri net. Should contain
N$Pre, a matrix representing the
N$Post, a matrix representing the RHS
N$h, a function representing the rates
of the reaction processes.
N$h should have
x, a vector representing the current state of
the system, and
t, a scalar representing the current
simulation time (in the typical time-homogeneous case,
will ignore this argument).
N$h may possess additional arguments, representing reaction rates, for example.
N does not need to contain an initial marking,
N$M will be ignored by most functions which use the resulting function closure.
Time step to be used by the simple Euler integration method. Defaults to 0.01.
An R function which can be used to advance the state of the SPN model
N by using an Euler method with step size
dt. The function closure has interface
t0 represent the initial state and time, and
deltat represents the amount of time by which the process should be advanced. The function closure returns a vector representing the simulated state of the system at the new time.
# load the LV model
# create a stepping function
stepLV = ()
# step the function
# integrate the process and plot it
out = ((x1=50,x2=100),0,100,0.1,stepLV)