Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tracing-subscriber = { version = "0.3.19", features = [
"time",
] }
faer = "0.24.0"
pharmsol = { version = "=0.29.0" }
pharmsol = "0.29.1"
anyhow = "1.0.100"
rayon = "1.10.0"
rand = "0.10.1"
Expand Down
5 changes: 1 addition & 4 deletions benches/bimodal_ke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ fn create_equation() -> equation::ODE {
params: [ke, v],
states: [central],
outputs: [outeq_1],
routes: [
infusion(input_1) -> central,
],
diffeq: |x, _t, dx| {
dx[central] = -ke * x[central];
dx[central] = infusion[input_1] - ke * x[central];
},
out: |x, _t, y| {
y[outeq_1] = x[central] / v;
Expand Down
4 changes: 1 addition & 3 deletions examples/bestdose/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ params = ke, v
states = central
outputs = outeq_0

bolus(input_0) -> central

dx(central) = -ke * central
dx(central) = bolus(input_0) - ke * central
out(outeq_0) = central / v
"#;

Expand Down
5 changes: 1 addition & 4 deletions examples/bimodal_ke/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ fn main() -> Result<()> {
params: [ke, v],
states: [central],
outputs: [outeq_1],
routes: [
infusion(input_1) -> central,
],
diffeq: |x, _t, dx| {
dx[central] = -ke * x[central];
dx[central] = infusion[input_1] - ke * x[central];
},
out: |x, _t, y| {
y[outeq_1] = x[central] / v;
Expand Down
9 changes: 2 additions & 7 deletions examples/bimodal_ke_backend_compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ params = ke, v
states = central
outputs = outeq_1

infusion(input_1) -> central

dx(central) = -ke * central
dx(central) = infusion(input_1) - ke * central

out(outeq_1) = central / v
"#;
Expand Down Expand Up @@ -78,11 +76,8 @@ fn macro_equation() -> equation::ODE {
params: [ke, v],
states: [central],
outputs: [outeq_1],
routes: [
infusion(input_1) -> central,
],
diffeq: |x, _t, dx| {
dx[central] = -ke * x[central];
dx[central] = infusion[input_1] - ke * x[central];
},
out: |x, _t, y| {
y[outeq_1] = x[central] / v;
Expand Down
3 changes: 1 addition & 2 deletions examples/chain_algorithms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ fn main() -> Result<()> {
params: [ke, v],
states: [central],
outputs: [outeq_1],
routes: [bolus(input_1) -> central],
diffeq: |x, _t, dx| {
dx[central] = -ke * x[central];
dx[central] = bolus[input_1] - ke * x[central];
},
out: |x, _t, y| {
y[outeq_1] = x[central] / v;
Expand Down
17 changes: 5 additions & 12 deletions examples/drusano/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,15 @@ fn main() -> Result<()> {
covariates: [ic_t],
states: [drug_1_amount, drug_2_amount, total_bacteria, resistant_1, resistant_2],
outputs: [outeq_1, outeq_2, outeq_3, outeq_4],
routes: [
bolus(input_1) -> drug_1_amount,
bolus(input_2) -> drug_2_amount,
],
diffeq: |x, _t, dx| {

let e50_2r1 = e50_2s;
let e50_1r2 = e50_1s;
let h2r1 = h2s;
let h1r2 = h1s;

dx[drug_1_amount] = -cl1 * x[drug_1_amount] / v1;
dx[drug_2_amount] = -cl2 * x[drug_2_amount] / v2;
dx[drug_1_amount] = bolus[input_1] - cl1 * x[drug_1_amount] / v1;
dx[drug_2_amount] = bolus[input_2] - cl2 * x[drug_2_amount] / v2;

let xns = x[total_bacteria];
let xnr1 = x[resistant_1];
Expand All @@ -32,20 +28,17 @@ fn main() -> Result<()> {

let u_s = x[drug_1_amount] / (v1 * e50_1s);
let v_s = x[drug_2_amount] / (v2 * e50_2s);
let w_s = alpha_s * u_s * v_s / (e50_1s * e50_2s);
let xm0best = get_e2(u_s, v_s, w_s, 1.0 / h1s, 1.0 / h2s, alpha_s);
let xm0best = estimate_effect_2(u_s, v_s, alpha_s, 1.0 / h1s, 1.0 / h2s);
dx[total_bacteria] = xns * (kgs * e - kks * xm0best);

let u_r1 = x[drug_1_amount] / (v1 * e50_1r1);
let v_r1 = x[drug_2_amount] / (v2 * e50_2r1);
let w_r1 = alpha_r1 * u_r1 * v_r1 / (e50_1r1 * e50_2r1);
let xm0best = get_e2(u_r1, v_r1, w_r1, 1.0 / h1r1, 1.0 / h2r1, alpha_s);
let xm0best = estimate_effect_2(u_r1, v_r1, alpha_r1, 1.0 / h1r1, 1.0 / h2r1);
dx[resistant_1] = xnr1 * (kgr1 * e - kkr1 * xm0best);

let u_r2 = x[drug_1_amount] / (v1 * e50_1r2);
let v_r2 = x[drug_2_amount] / (v2 * e50_2r2);
let w_r2 = alpha_r2 * u_r2 * v_r2 / (e50_1r2 * e50_2r2);
let xm0best = get_e2(u_r2, v_r2, w_r2, 1.0 / h1r2, 1.0 / h2r2, alpha_s);
let xm0best = estimate_effect_2(u_r2, v_r2, alpha_r2, 1.0 / h1r2, 1.0 / h2r2);
dx[resistant_2] = xnr2 * (kgr2 * e - kkr2 * xm0best);
},
init: |_t, x| {
Expand Down
5 changes: 1 addition & 4 deletions examples/meta/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ fn main() -> Result<()> {
covariates: [wt, pkvisit],
states: [central, metabolite],
outputs: [outeq_1, outeq_2],
routes: [
infusion(input_1) -> central,
],
diffeq: |x, _t, dx| {
let cl = cls * ((pkvisit - 1.0) * theta1).exp() * (wt / 70.0).powf(0.75);
let v = vs * ((pkvisit - 1.0) * theta2).exp() * (wt / 70.0);
let ke = cl / v;
dx[central] = -ke * x[central] * (1.0 - fm) - fm * x[central];
dx[central] = infusion[input_1] - ke * x[central] * (1.0 - fm) - fm * x[central];
dx[metabolite] = fm * x[central] - k20 * x[metabolite];
},
out: |x, _t, y| {
Expand Down
5 changes: 1 addition & 4 deletions examples/neely/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ fn main() -> Result<()> {
covariates: [wt, pkvisit],
states: [central, peripheral, metabolite_1, metabolite_2],
outputs: [outeq_1, outeq_2, outeq_3],
routes: [
infusion(input_1) -> central,
],
diffeq: |x, _t, dx| {
let cl = cls * ((pkvisit - 1.0) * theta1).exp() * (wt / 70.0).powf(0.75);
let q = qs * (wt / 70.0).powf(0.75);
Expand All @@ -19,7 +16,7 @@ fn main() -> Result<()> {
let k12 = q / v;
let k21 = q / vp;

dx[central] = -ke * x[central] * (1.0 - fm1 - fm2)
dx[central] = infusion[input_1] - ke * x[central] * (1.0 - fm1 - fm2)
- (fm1 + fm2) * x[central]
- k12 * x[central]
+ k21 * x[peripheral];
Expand Down
5 changes: 1 addition & 4 deletions examples/two_eq_lag/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ fn main() -> Result<()> {
params: [ka, ke, tlag, v],
states: [gut, central],
outputs: [outeq_0],
routes: [
bolus(input_0) -> gut,
],
diffeq: |x, _t, dx| {
dx[gut] = -ka * x[gut];
dx[gut] = bolus[input_0] - ka * x[gut];
dx[central] = ka * x[gut] - ke * x[central];
},
lag: |_t| {
Expand Down
5 changes: 1 addition & 4 deletions examples/vanco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ fn main() -> Result<()> {
params: [ke, kcp, kpc],
states: [central, peripheral],
outputs: [peripheral_amount],
routes: [
bolus(dose) -> central,
],
diffeq: |x, _t, dx| {
dx[central] = -ke * x[central] - kcp * x[central] + kpc * x[peripheral];
dx[central] = bolus[dose] - ke * x[central] - kcp * x[central] + kpc * x[peripheral];
dx[peripheral] = -kpc * x[peripheral] + kcp * x[central];
},
init: |_t, x| {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub mod prelude {

// Items required by downstream code that are not part of `pharmsol::prelude`.
pub use pharmsol::equation::{EquationTypes, Predictions};
pub use pharmsol::optimize::effect::get_e2;
pub use pharmsol::optimize::effect::{estimate_effect_2, estimate_effect_3};
pub use pharmsol::{ODE, SDE};

// Organized submodules mirroring pharmsol's grouping.
Expand Down
10 changes: 2 additions & 8 deletions tests/bestdose_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ fn bolus_model() -> ODE {
params: [ke, v],
states: [central],
outputs: [outeq_0],
routes: [
bolus(input_0) -> central,
],
diffeq: |x, _t, dx| {
dx[central] = -ke * x[central];
dx[central] = bolus[input_0] - ke * x[central];
},
out: |x, _t, y| {
y[outeq_0] = x[central] / v;
Expand All @@ -37,11 +34,8 @@ fn infusion_model() -> ODE {
params: [ke, v],
states: [central],
outputs: [outeq_0],
routes: [
infusion(input_0) -> central,
],
diffeq: |x, _t, dx| {
dx[central] = -ke * x[central];
dx[central] = infusion[input_0] - ke * x[central];
},
out: |x, _t, y| {
y[outeq_0] = x[central] / v;
Expand Down
Loading