-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Facilitating user-provided propensity calculations #34
Comments
This does seem like a desirable feature, even if these alternative propensity functions aren't as well founded as the typical mass-action-kinetic forms. I think (1) would provide a richer compliment of features (i.e. I think (2) is easy to emulate with (1), but not vice-versa). Ideally it would be possible to call compiled functions from native C code rather than needing to pass through a Python layer, though short of writing a modeling sublanguage (like Theano and other tools) I'm not sure how this could be accomplished elegantly. It might be most practical to write the needed propensity function in C. |
Further thoughts: maybe the healthy middle ground would be to implement compiled 'metafunctions'. The current approach is like a metafunction (by which I mean a function that returns functions) in that we provide some information (which molecules participate in a reaction) and in turn it caches all the information needed to (re)evaluate that particular function efficiently (indices, dependencies, etc.). |
Thanks, @jmason42! I agree:
@prismofeverything and I got a chance to sketch the implementation of this route -- I'll start a branch for this feature. |
FYI: A “higher order function” is the term for a function that returns functions and/or takes functions as arguments. |
Yeah, I suppose a metafunction wouldn't be a function emitter so much as something that modifies how functions work. (Incidentally there is a concept called a 'metafunction' that has nothing to do with programming and has one of the most baffling Wikipedia entries 🤣 .) |
A helpful feature for systems with alternative propensity calculations (such as when stochastic constants are unavailable) might be support for externally provided propensities. For example, each reaction:
X + Y -> Z
may have an associated propensity function described by the user that depends on the counts of molecules at each iteration:
which returns a value that represents the propensity for this reaction, for this iteration. Since the inputs (X and Y) are dynamic during the simulation, the return value from
get_propensity()
also varies during the simulation.Two candidate approaches to supporting this feature might be providing a way for the user:
get_propensity()
is called inside arrow)get_propensity()
is called outside arrow by the user)The text was updated successfully, but these errors were encountered: