tgvaughan / MASTER

A versatile simulation engine for stochastic population dynamics models.
http://tgvaughan.github.io/MASTER
GNU General Public License v3.0
22 stars 8 forks source link

frequency-dependent rates #25

Closed sdwfrost closed 1 year ago

sdwfrost commented 10 years ago

@tgvaughan , nice job on MASTER, it could potentially save me a lot of time. This is more of a feature query/request; in many epidemiological models, infection is of the form b_S_I/N where N is the total population size, rather than b_S_I. Is there a way to implement this in the current build, or if not, could this be added?

tgvaughan commented 10 years ago

Thanks, Simon; it's great to hear that you're finding it useful. Unfortunately there's no way to do this currently (unless N is constant, but I don't think you're asking about that). A couple of other people have asked me about this though, so I have been thinking seriously about adding it. Basically, I'd have a parser for simple mathematical expressions handle the value of the rate attribute, allowing explicit dependence on times and population sizes.

I've marked this issue as a feature request, and I'll write back here when I have something further to report.

Thanks again!

tgvaughan commented 9 years ago

Could incorporate this into the rate multiplier!

ekankaka commented 4 years ago

Hi Tim. Thanks for MASTER. I want to create a population-dependent rate. Specifically, the antigen-driven T-Cell and Macrophage proliferation rates in model (14) of this paper vary with amount of Virus (V) - which is included in the numerator and denominator. I created the function below, and then used it in a rate multiplier, but keeps throwing the error when i run the file in BEAST: "validate and intialize error: Variable V in predicate expression was not found in reaction string. " I got the same error even when i made unifected T cells, infected T cells, and Virus demes of the same population (T[0] and T[1], and T[2] respectively). How can i solve this in MASTER?

    <!-- Function -->
    <function spec='Function' id='freqDepRateMultiplier' params="x">
      { (0.01 * x) / (300 + x) }
    </function>

    <!-- Reaction -->
     <reaction spec='Reaction' rate="1">
        <rateMultiplier spec="RateMultiplier" value="freqDepRateMultiplier(V)"/>
        T + V -> 2T + V
     </reaction>
tgvaughan commented 4 years ago

Hi @ekankaka, glad you're finding it useful.

Sadly this still isn't possible to do in MASTER - rates are assumed to be constant w.r.t. population sizes. (That is, the overall master equation is still assumed to be of the form described in equation 1 of the documentation) The comment I made above was just to note down the possibility of extending the functionality of the rate multipliers to handle this, but the extension hasn't been implemented.

The reason you're seeing the error you're seeing is that MASTER is specifically looking for population index variables (such as i in T[i]) in your reaction string. It doesn't consider V a variable (it's a population type).