epirecipes / sir-julia

Various implementations of the classical SIR model in Julia
MIT License
195 stars 39 forks source link

Add Fleck.jl example #110

Closed sdwfrost closed 5 months ago

sdwfrost commented 8 months ago

Modify this example from @slwu89

slwu89 commented 8 months ago

Nice! I think I may have an idea about how to use Fleck.jl to implement an operad algebra style of composition to build models by gluing Poisson processes together, i.e. the long running issue here https://github.com/AlgebraicJulia/AlgebraicDynamics.jl/issues/38

But I'll need to wait for break when I'll have a chance to think about it in more detail.

Also the vector addition system wrapper for the samplers in Fleck was quite barebones and really just a proof of concept. Happy to hear any suggestions on how to improve it. I guess interoperability with AlgPetri would be a start.

sdwfrost commented 8 months ago

I've been playing with your example @slwu89 - I had to change the name of sampler to smplr due to a name clash in Distributions.jl. I also couldn't access many of the samplers you put (including those in comments). As this is an exponential sampler, smplr = DirectCall{Int}() worked, as did CombinedNextReaction.

I also tried to extend to the Gamma(4,1) scenario for recovery rates (as in this example), but although it ran, it wasn't giving the right result.

sdwfrost commented 8 months ago

@slwu89 - how's this?

slwu89 commented 8 months ago

@sdwfrost the Gamma(4,1) not working is strange and disturbing...I'll check that out.

slwu89 commented 5 months ago

@sdwfrost so I forgot that the VAS was not set up to handle non-exponential distributions. The package itself works perfectly fine for any type of distribution at all, but the VAS wasn't. The issue is that the VAS assumes that each event only needs a single clock (because all events have identical rate and the hazards are simply summed). To do a Gamma(4,1) for recovery times would need to send a new clock key to the sampler each time that transition was enabled.

I'm happy to expand the example to include some actual non-Markovian dynamics (including Dirac delays) but I am once again having some compatibility problems with the various packages in the Project.toml file in the repo. How did you get Fleck to install and precompile? It needs a more recent version of Distributions than the version that Julia's package manager is able to install for me, given the various constraints between packages in the repo (see below).

(sir-julia) pkg> st Distributions
Status `~/Desktop/git/sir-julia/Project.toml`
⌅ [31c24e10] Distributions v0.23.8
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated`
sdwfrost commented 5 months ago

I need to get rid of that repo-wide Project.toml; after a certain number of examples, it just becomes too difficult to maintain compatibility. I just use an example-specific env for tricky examples (Pkg.activate/instantiate).

slwu89 commented 5 months ago

I think this is good to close with #111. @sdwfrost note that I didn't regenerate the notebooks, etc because I'm not sure how the folder specific Project.toml will interact with root dir Project.toml.

sdwfrost commented 5 months ago

Thanks @slwu89! Closing as suggested. Still lots more to go...

slwu89 commented 5 months ago

Hah, of course. Hopefully I will revisit the Fleck example in the future after we develop some exciting new features (already have common random numbers worked in it; working on other helpful tools for calibration).