MODERATOR NOTE: coronavirus resources & updates: ⭐ [COVID] Computational Research HUB For Novel Coronavirus: Data, Code, Visualizations, Notebooks - Staff Picks - WOLFRAM COMMUNITY
DOWNLOAD-DESKTOP-NOTEBOOK.nb (5.25 MB)
MODERATOR NOTE: coronavirus resources & updates: ⭐ [COVID] Computational Research HUB For Novel Coronavirus: Data, Code, Visualizations, Notebooks - Staff Picks - WOLFRAM COMMUNITY
DOWNLOAD-DESKTOP-NOTEBOOK.nb (5.25 MB)
– you have earned Featured Contributor Badge ![]()
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!
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 ( Stochastic epidemiology models with applications to the COVID-19 ) so many more interested readers will become aware of your excellent work. Thank you for your contribution!
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}
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).
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 ?
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.
Really Thanks for your helpful.
But there are some problem as
In[79]:= {times, states} = Transpose@Normal@stateList;
states = Transpose@states;
During evaluation of In[79]:= Set::shape: Lists {times,states} and Transpose[CreateDataStructure[DynamicArray]] are not the same shape.
During evaluation of In[79]:= $RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of Transpose[states].
Next, we compute InterpolatingFunction objects for each variable. Note that runs of constant state are replaced by just the first instance, and that we use an interpolation order of 0.
In[81]:= soln = First@{Thread[
vars → (Interpolation[
Join @@ Replace[
SplitBy[Thread[{times, #}], Last], {a_, __, z} :> {a}, {1}],
InterpolationOrder → 0] & /@ states)]}
During evaluation of In[81]:= $RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of Transpose[states].
Out[81]= Hold[soln =
First[{Thread[
vars → (Interpolation[
Join @@ Replace[
SplitBy[Thread[{times, #1}], Last], {a_, __, z} :> {a}, {1}],
InterpolationOrder → 0] &) /@ states]}]]
also in comparison plotting the charts of stochastic are empty
plot comparison.pdf (84.9 KB)
The stochastic simulation is not running properly because it’s trying to use the CreateDataStructure function which is not in version 12.0.
Let me see what it takes to run the notebook in version 12.0, and then send you either a short list of changes, or a new notebook. I might not be able to get to this until Wednesday, however.
Thank you for your help.
To run the notebook for this post in version 12.0 of Mathematica make the following changes:
Replace the first input
<<CompartmentalModeling`
with
Get@CloudObject["https://www.wolframcloud.com/obj/rnachbar/Published/CompartmentalModeling.wl"]
Replace all instances of stochasticSolve with StochasticSolve
Don’t evaluate the input in the section “Simulation loop”