GithubHelp home page GithubHelp logo

adolgert / competingclocks.jl Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 0.0 12.52 MB

Simplest simulation to use non-Exponential transitions

License: MIT License

Julia 100.00%
continuous-time discrete-event-systems gillespie-algorithm stochastic-simulation generalized-semi-markov-processes next-reaction-method

competingclocks.jl's Introduction

  • Stochastic processes for epidemiology
  • Computational demography
  • Distributed, parallel, high-performance computing
  • Provenance systems

competingclocks.jl's People

Contributors

adolgert avatar slwu89 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

competingclocks.jl's Issues

issue with make.jl

@adolgert when running docs/make.jl for some reason the distributions.md and various pngs from it are still being dumped into docs/src/ which will mess up the deployment. Not sure why.

image

Delete `FixedDirect`

It looks like src/sample/fixeddirect is from an older version and does not observe the interface defined for SSA types. Should we get rid of it?

Interface for samplers

When drafting #15 I thought about the benefits of enforcing a more strict interface (in code that is) for samplers. What do you think about making an abstract AbstractSampler supertype of all sampler types and defining the interface functions next, etc. for it, which must be implemented for subtypes?

inconsistencies in type parameters for samplers

FirstToFire takes K,T as type parameters, for keys and the type that stores time. Other samples (CombinedNextReaction) and others only take a key type parameter. We should try to make them all take the same number of type parameters, if possible.

Demonstrate importance sampling with splitting

We should demonstrate a common technique for importance sampling. If there is a rare event, and the simulation nears that event, then split the simulation into multiple copies, weighting each by the fraction of the split, in order to improve statistics on the rare event. This requires a copy operation for the sampler and for the rest of the simulation, but it is otherwise simple.

CI triggers

I suggest that we only trigger CI runs when doing something like opening a PR to main, I tend to commit frequently when working and I don't necessarily expect every commit will pass, and would rather only trigger CI when I'm ready to open a PR for a block of work that I think is nearing completion and has a good chance of passing.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Example of Benders decomposition for structural optimization of dependent stochastic model

@adolgert I inteded to bring this up on one of our Friday meetings but there was a recent article with associated repo here (https://github.com/mitchopt/Combining-Optimization-and-Simulation-Using-Logic-Based-Benders-Decomposition) describing optimization of planning (number of machines, flow layout, etc) where each feasible solution is evaluated via DES. I need to go back and read the paper more carefully, but it should be a nice example.

VAS with non-exponential clocks

It's common to want to add non-exponential clocks to systems specified via VAS. For example, in the SIR example below, its quite reasonable to want the recovery clock to follow (for example) a Weibull distribution. However, for this SIR example this means that we cannot use the same machinery to specify the VAS, if we want each infectious period to be drawn from that Weibull distribution.

I don't know the best way to specify these kinds of systems but they are extremely common, so we should think about the best way to do so. As written below is clearly wrong, but any generalization of the VAS machinery to support these systems should only introduce minimal complications at the user facing level.

function sir_vas(β, c, γ)
    take = [
        1 0;
        1 1;
        0 0;
    ]
    give = [
        0 0;
        2 0;
        0 1;
    ]
    rates = [(state) -> Exponential(1.0/*c*state[2]/sum(state)*state[1])), (state) -> Weibull(...))]
    (take, give, rates)
end

Add example of distribution driven by an ODE

This would be a distribution that is a delta function, where the time of the distribution comes from an ordinary differential equation (ODE) that depends on the state of the system.

Mutable pairing heap

The Fibonacci heap is overkill for all but the largest simulations, so implement a mutable pairing heap. It's a simpler algorithm that runs faster in most cases.

composition of hierarchical samplers

Based on the compositional-hierarchical samplers in the book https://link.springer.com/book/10.1007/978-3-319-63113-4 we should be able to use undirected wiring diagrams to compose (i.e. black box combine) samplers for semi-Markov processes.

For the first proof of concept cases, we should consider models where observables and physical state are the same, and that they alone are sufficient to compute the hazards. That is, Markov processes. It's possible semi-Markov processes complicate things a bit, and multiple types of junction and port would be needed, but we can kick that can down the road.

Add ability to perform Hamiltonian Monte Carlo

Hamiltonian Monte Carlo samples a probability space of all possible trajectories, such that the trajectories are weighted according to their likelihood. This technique doesn't use a sampler to decide the set of possible trajectories, but it could use the samplers in CompetingClocks to calculate the likelihood of the chosen trajectories.

You set up a simulation with a modest number of events in each trajectory. You decide some observations of events. Then sample the space of trajectories consistent with those events. It sounds much harder than it is. It's a very good technique for this library.

abstract type for samplers

This is highly related to #35; we should have an abstract sampler type. This helps users write applications using the library, for example, a user might reasonably want to do something like:

function myfunc(sampler::AbstractSampler{KeyType}) where {KeyType}
   # do something with KeyType
end

First reaction examples

If I understand correctly, the first reaction method should be good to go immediately to start implementing semi-Markov examples. We'd want a couple to show off some common cases:

  1. homogeneous Markov (in the PR #10)
  2. inhomogeneous Markov (e.g. SIR with $\beta$ following a sine curve for "seasonality")
  3. homogeneous semi-Markov with Dirac distribution (e.g. SIR but with deterministic I to R transition)
  4. inhomogeneous semi-Markov (e.g. example 2 but with some non-exponential distribution on the I to R transition)

There are more of interest, but these should be sufficient for now. Using the Dirac distribution means that we'd want to be able to support MeasureTheory.jl which implements a Dirac "distribution". See a very silly example I made here of using Dirac distributions as the transition kernel of a Markov chain to simply count on the integers, perhaps one of the most baroque ways to count on the integers https://gist.github.com/slwu89/a54ad60c047fad23741213ce7aa09e97

topics for meet

Just going to use this issue to record some things for our next meeting:

  • let's rename cumulant in next reaction to survival if you are ok with that; cumulant is obscure, and not the same as the terminology as the counting processes paper
  • there seems to be a bug in consume_cumulant
  • sample_by_inversion might also have something wrong, when te<when, the shifted distribution seems wrong.
  • why does enable! for next reaction resample for anything that was previously enabled? Only the survival of the process that jumped should resample the survival. The rest should just consume survival according to the time process $L_{j}$.
  • testing: how do we test semi-markov models with transitions that will be enabled, disabled, enabled again, etc?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.