In the iteration loop for the Gillespie algorithm, there is a reference to compartments. The algorithm should be more generic (not only used for epidemiological models).
doGillespieIteration: t
| rates deltaT chosen transitions |
rates := OrderedCollection new.
model t: t.
transitions := model transitions.
transitions
do: [ :tr |
| prob |
(tr from at: #status) = #empty
ifTrue: [ model currentCompartment: tr to ]
ifFalse: [ model currentCompartment: tr from ].
model nextCompartment: tr to.
prob := (tr probability value: model) abs.
rates add: prob * (model atCompartment: tr from) ].
rates sum = 0
ifTrue: [ ^ 0.0 ].
deltaT := rand2 next ln negated / rates sum.
chosen := self rouletteWheelSelectAmong: rates.
(transitions at: chosen) executeOn: model times: 1.
^ deltaT
In the iteration loop for the Gillespie algorithm, there is a reference to compartments. The algorithm should be more generic (not only used for epidemiological models).
Same problem in TauLeap iteration loop.