Group Abstract Group Abstract

Message Boards Message Boards

Stochastic epidemiology models with applications to the COVID-19

MODERATOR NOTE: coronavirus resources & updates: https://wolfr.am/coronavirus


Stochastic simulation of SEIR model

Attachments:
POSTED BY: Robert Nachbar
11 Replies

To run the notebook for this post in version 12.0 of Mathematica make the following changes:

1) Replace the first input

<<CompartmentalModeling`

with

Get@CloudObject["https://www.wolframcloud.com/obj/rnachbar/Published/CompartmentalModeling.wl"]

2) Replace all instances of stochasticSolve with StochasticSolve

3) Don't evaluate the input in the section "Simulation loop"

POSTED BY: Robert Nachbar

Thank you for your help.

POSTED BY: Moustafa Salama
POSTED BY: Robert Nachbar
Attachments:
POSTED BY: Moustafa Salama
POSTED BY: Moustafa Salama

Try using the StochatsticSolve function in my package

CloudObject["https://www.wolframcloud.com/obj/rnachbar/Published/CompartmentalModeling.wl"]

instead of stochasticSolve used in the Community post notebook. Use the option Compiled -> True (the default), and it should use the fixed-length memory version of the Gillespie algorithm.

POSTED BY: Robert Nachbar

First I 'd like to thank you for you kind reply. Really I have version 12. How can I fix the problem in version 12 ?

POSTED BY: Moustafa Salama

What version of Mathematica are you using?

Version 12.1 or newer is required to use the new built-in data structures that are used by the stochastic simulation code (for example, CreateDataStructure).

POSTED BY: Robert Nachbar

Please I have the following error while evaluating you notebook

In[369]:= SeedRandom[1425367]
solnsCME = 
   Table[stochasticSolve[modelData["Rates"] /. paramsN, 
     modelData["StoichiometricMatrix"], 
     Through@modelData["Variables"][0] /. Rule @@@ inits /. paramsN, 
     modelData["Variables"], {t, 0, tmax}], 500]; // Timing

During evaluation of In[369]:= Set::shape: Lists {times$25658,states$25658} and Transpose[CreateDataStructure[DynamicArray]] are not the same shape.

During evaluation of In[369]:= $RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of Transpose[states$25658].

During evaluation of In[369]:= $RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of Transpose[states$25658].

During evaluation of In[369]:= Set::shape: Lists {times$25667,states$25667} and Transpose[CreateDataStructure[DynamicArray]] are not the same shape.

During evaluation of In[369]:= $RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of Transpose[states$25667].

During evaluation of In[369]:= General::stop: Further output of $RecursionLimit::reclim2 will be suppressed during this calculation.

During evaluation of In[369]:= Set::shape: Lists {times$25682,states$25682} and Transpose[CreateDataStructure[DynamicArray]] are not the same shape.

During evaluation of In[369]:= General::stop: Further output of Set::shape will be suppressed during this calculation.

Out[370]= {78.5, Null}
POSTED BY: Moustafa Salama

This post has been listed in the main resource-hub COVID-19 thread: https://wolfr.am/coronavirus in the section Computational Publications. Please feel free to add your own comment on that discussion pointing to this post ( https://community.wolfram.com/groups/-/m/t/1980051 ) so many more interested readers will become aware of your excellent work. Thank you for your contribution!

POSTED BY: EDITORIAL BOARD

enter image description here -- you have earned Featured Contributor Badge enter image description here

Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard