SciML / Catalyst.jl

Chemical reaction network and systems biology interface for scientific machine learning (SciML). High performance, GPU-parallelized, and O(1) solvers in open source software.
https://docs.sciml.ai/Catalyst/stable/
Other
437 stars 71 forks source link

Enabling creation of bundled reactions (using vector variables/parameters) #947

Open TorkelE opened 3 weeks ago

TorkelE commented 3 weeks ago

Imagine if we have a vector-valued species:

using Catalyst
t = default_t()
@species X[1:100]

where each degrades at the same rate d, it would be neat to declare this as a single reaction:

@parameters d
rxs = Reaction(d, X, [])

If we could somehow represent this as a single reaction, without unfolding it into 100 different one, we might utilise the new JuliaSimCompiler to gain a lot of efficiency.

This concept is quite similar to the limited reaction bundling we already do in the DSL (although these are unfolded into multiple reactions):

rn = @reaction_network begin
    p, 0 --> X1
    k1, X1 --> X2
    k2, X2 --> X3
    d, (X1, X2, X3) --> 0 # The three degradation reaction bundles into a single line
end

At some point, it might be possible to create a general bundled reaction structure and use it under these circumstances.

I am not sure what the status of JuliaSimCompiler is though. If we wish to hook into it, we should probably want until that is fully settled.

isaacsas commented 3 weeks ago

I think this starts getting into wanting to support something akin to the BNGL language, which has all kinds of expressiveness to specify collections of reactions. Building up such functionality would be great (though I have to say I find bngl super confusing / hard to read so I'm not sure we should just mimic their approach).

TorkelE commented 3 weeks ago

That's a good point, sounds like something like this and https://github.com/SciML/Catalyst.jl/issues/703 is probably better handled at the same time.

Going in this direction would be a very significant endeavour though, probably best just keeping in mind that we might want to go there for now, and store any related ideas we have.

isaacsas commented 3 weeks ago

There are I guess two aspects here, vectorizing the generated mathematical models and a more flexible DSL for specifying collections of reactions with similar structure. The later is what I was refering to with BNGL, but could presumably hook into both flattening of the models (expanding all reactions) and something like an equation free solver should we ever get that setup.