Skip to content

Commit a431b73

Browse files
quffaroepatters
andauthored
ENH: Stochastic mass-action dynamics for Petri nets (#619)
--------- Co-authored-by: Evan Patterson <evan@epatters.org>
1 parent 78df528 commit a431b73

File tree

7 files changed

+257
-24
lines changed

7 files changed

+257
-24
lines changed

Cargo.lock

Lines changed: 75 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/catlog-wasm/src/theories.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use catlog::stdlib::{analyses, models, theories, theory_morphisms};
1414
use catlog::zero::name;
1515

1616
use super::model_morphism::{MotifOccurrence, MotifsOptions, motifs};
17+
use super::result::JsResult;
1718
use super::{analyses::*, model::DblModel, theory::DblTheory};
1819

1920
/// The empty or initial theory.
@@ -335,6 +336,21 @@ impl ThSymMonoidalCategory {
335336
.into(),
336337
))
337338
}
339+
340+
/// Simulates the stochastic mass-action system derived from a model.
341+
#[wasm_bindgen(js_name = "stochasticMassAction")]
342+
pub fn stochastic_mass_action(
343+
&self,
344+
model: &DblModel,
345+
data: analyses::ode::MassActionProblemData,
346+
) -> Result<ODEResult, String> {
347+
Ok(ODEResult(JsResult::Ok(
348+
analyses::ode::PetriNetMassActionAnalysis::default()
349+
.build_stochastic_system(model.modal()?, data)
350+
.simulate(),
351+
)))
352+
}
353+
338354
/// Solve the subreachability problem for petri nets.
339355
#[wasm_bindgen(js_name = "subreachability")]
340356
pub fn subreachability(

packages/catlog/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2024"
77

88

99
[features]
10-
ode = ["dep:ode_solvers", "dep:nalgebra"]
10+
ode = ["dep:ode_solvers", "dep:nalgebra", "dep:rebop"]
1111
serde = ["dep:serde", "nonempty/serialize", "ustr/serde", "uuid/serde"]
1212
serde-wasm = ["serde", "dep:wasm-bindgen", "dep:tsify", "dep:instant", "instant/wasm-bindgen"]
1313

@@ -27,6 +27,7 @@ nonempty = "0.12"
2727
num-traits = "0.2"
2828
ode_solvers = { version = "0.5.0", optional = true }
2929
pretty = "0.12.4"
30+
rebop = { git = "https://github.com/Armavica/rebop.git", rev = "eb1e500", default-features = false, optional = true }
3031
ref-cast = "1"
3132
scopeguard = "1.2.0"
3233
serde = { version = "1", features = ["derive"], optional = true }

0 commit comments

Comments
 (0)