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 observables in the DSL #735

Closed
wants to merge 149 commits into from
Closed

Enable observables in the DSL #735

wants to merge 149 commits into from

Conversation

TorkelE
Copy link
Member

@TorkelE TorkelE commented Dec 1, 2023

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?

@TorkelE
Copy link
Member Author

TorkelE commented Dec 1, 2023

(This PR is built upon #718)

@TorkelE TorkelE force-pushed the enable_dsl_observed branch from 0244425 to 4af9252 Compare December 20, 2023 15:17
@TorkelE TorkelE force-pushed the enable_dsl_observed branch from 4af9252 to 7e16792 Compare December 20, 2023 15:30
@TorkelE TorkelE closed this Dec 20, 2023
@TorkelE TorkelE reopened this Dec 20, 2023
@TorkelE TorkelE mentioned this pull request Jan 25, 2024
@TorkelE TorkelE force-pushed the enable_dsl_observed branch from e5769d5 to a9b176d Compare January 25, 2024 15:02
@isaacsas
Copy link
Member

@TorkelE Can we close this PR since we are using the other one now? It is just causing extraneous CI to be run...

@TorkelE TorkelE closed this Jan 25, 2024
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