Skip to content
William Poole edited this page Jun 19, 2019 · 3 revisions

Types of delays

The delays are also specified by a type and relevant fields. A delay must be specified for each reaction.

No Delay

<delay type="none" />

If there is no delay, just use this tag to specify that there is no delay.

Fixed Delay

<delay type="fixed" delay="param1" />

If the delay is a fixed constant, then set the delay to a fixed constant specified by the parameter param1.

Gaussian Delay

<delay type="gaussian" mean="m" std="s">

If the delay is Gaussian, then it is distributed according to a normal distribution with mean parameter mean and standard deviation parameter std.

Gamma Distributed Delay

<delay type="gamma" k="k1" theta="theta1" />

If the delay is distributed with a gamma distribution as is commonly the case in biological circuits, then you can specify that the delay type is gamma with k1 and theta1 being parameters that contain the k and theta parameters of the gamma distribution.

The Delay Queue

To do simulations with delay, you must create a delay queue object that stores reactions that have been queued up to happen in the future. This is part of the initial state because the initial state is both the current species level as well as any reactions that have been queued up to occur. Currently, the only type of delay queue object available is called an ArrayDelayQueue and one can be created with the code

q = ArrayDelayQueue.setup_queue(num_reactions, num_timepoints, dt)

This will create a delay queue that is capable of storing events up to num_timepoints*dt time units into the future with a temporal resolution of dt. Making dt smaller makes your timing more accurate, but will make your code slower. It will especially slow things down when you simulate cell division. You should select a suitable dt, and then select num_timepoints to be such that the maximum possible storeable delay is big enough for your purposes. The num_reactions parameter should be picked based on your system of reactions. If you want to add reactions to the queue, you can do so using the following code.

q.py_add_reaction(time, rxn_id, amount)

The time is the time that the reaction occurs, the reaction ID is the index of that reaction in the stoichiometric matrix, and the amount is the number of times you want that reaction to fire at the specified time. This would typically be 1.0 since the reaction would usually fire once in a stochastic simulation, but in some cases you might want it to fire multiple times. If you want to set up a delay simulation with reactions queued up as part of the initial state, you can create a queue and use py_add_reaction() to pre-queue reactions that will occur.

Specifying Custom Delay Objects:

TODO