Skip to content
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

Enable dsl observed #771

Merged
merged 37 commits into from
Jan 25, 2024
Merged

Enable dsl observed #771

merged 37 commits into from
Jan 25, 2024

Conversation

TorkelE
Copy link
Member

@TorkelE TorkelE commented Jan 25, 2024

Merges #735 into v14.

Original PR test:

Enables observables to be created as a part of the DSL. Example:

using Catalyst 
rn = @reaction_network begin
  @observables begin
    X ~ Xi + Xa
  end
  (p,d), 0 <--> Xi
  (k1,k2), Xi <--> Xa
end

if we simulate the system, the observables can now be used for indexing:

using OrdinaryDiffEq
@unpack Xi, Xa, X, p, d, k1, k2 = rn
u0 = [Xi => 0.0, Xa => 0.0]
ps = [p => 1.0, d => 0.2, k1 => 1.0, k2 => 2.0]
oprob = ODEProblem(rn, u0, (0.0, 10.0), ps)
sol = solve(oprob, Tsit5())
sol[X]
using Plots
plot(sol; idxs=X)

Some additional notes:

  • If only a single observable is used, the begin ... end block is not required:
  @observables X ~ Xi + Xa
  (p,d), 0 <--> Xi
  (k1,k2), Xi <--> Xa
end
  • The right-hand side can have any algebraic expression. However, all stuff there must be declared elsewhere (and it cannot contain other observables).
  • Currently, the observables do not have any independent variables. We might want to change this part (although it will require a decent amount of coding).
  • Metadata for observables is not supported either. This should probably be added I think, but not sure.

Tests and docs are here, so in principle this is ready
(unless we want to support independent variables in this PR)

Consideration regarding independent variables for observables: If the thing it consists of has several different ones, the iv for the observable should be the union of all those occurring in its formula, right?

Copy link
Member

@isaacsas isaacsas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Can you add a test that when predeclaring a species or variable observable it doesn't end up in states(sys) or species(sys)?
  • I wasn't quite clear -- should this be correctly inferring ivs as the union of the rhs terms?
  • Can you add a check that interpolation of an external variable/species/parameter works on the lhs of an observable?

docs/src/catalyst_functionality/dsl_description.md Outdated Show resolved Hide resolved
docs/src/catalyst_functionality/dsl_description.md Outdated Show resolved Hide resolved
src/reaction_network.jl Outdated Show resolved Hide resolved
src/reactionsystem.jl Outdated Show resolved Hide resolved
test/dsl/dsl_options.jl Show resolved Hide resolved
test/dsl/dsl_options.jl Outdated Show resolved Hide resolved
test/dsl/dsl_options.jl Outdated Show resolved Hide resolved
TorkelE and others added 4 commits January 25, 2024 14:47
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
@TorkelE
Copy link
Member Author

TorkelE commented Jan 25, 2024

I will add additional tests. Yes, the ivs of the observables is the same as the ivs of the right hand stuff (the union, using the order with which they appear in the actual reaction network.

@TorkelE TorkelE dismissed isaacsas’s stale review January 25, 2024 21:39

fixed requested changes

@TorkelE TorkelE merged commit ef0a40c into Catalyst_version_14 Jan 25, 2024
2 checks passed
@TorkelE TorkelE deleted the enable_dsl_observed branch June 8, 2024 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants