GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — pharmsol/examples/dsl_runtime.rs at main · LAPKB/pharmsol Expand file tree/ Copy pathdsl_runtime.rsMore file actions 86 lines (72 loc) · 2.39 KB / Copy pathdsl_runtime.rsFile metadata and controls86 lines (72 loc) · 2.39 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 //! Demonstrates JIT compilation of an ODE model from DSL source text. //! //! A simple one-compartment IV infusion model is defined as a DSL string, //! compiled at runtime via `compile_module_source_to_runtime`, and then used //! to estimate predictions — no recompilation of the host binary needed. //! //! Run with: //! cargo run --example dsl_runtime --features dsl #[cfg(feature = "dsl")] fn main() -> Result<(), Box<dyn std::error::Error>> { use std::io; use pharmsol::{prelude::*, Parameters}; let model_source = r#" name = bimodal_ke kind = ode params = ke, v states = central outputs = cp dx(central) = infusion(iv) - ke * central out(cp) = central / v "#; let show_compile_logs = false; let on_compile_event = move |kind: String, message: String| { if !show_compile_logs || message.is_empty() { return; } if kind == "log" { eprint!("{message}"); } else { eprintln!("[compile:{kind}] {message}"); } }; // 1. Compile the model to the runtime JIT backend. let model = pharmsol::dsl::compile_module_source_to_runtime( model_source, Some("bimodal_ke"), on_compile_event, )?; let support_point = Parameters::with_model(&model, [("ke", 1.2), ("v", 50.0)])?; // 3. Define the subject data. let subject = Subject::builder("bimodal_ke") .infusion(0.0, 500.0, "iv", 0.5) .missing_observation(0.5, "cp") .missing_observation(1.0, "cp") .missing_observation(2.0, "cp") .missing_observation(3.0, "cp") .missing_observation(4.0, "cp") .missing_observation(6.0, "cp") .missing_observation(8.0, "cp") .build(); // 4. Estimate predictions for one support point. let predictions = model .predict(&subject, &support_point)? .into_subject() .ok_or_else(|| io::Error::other("expected subject predictions"))?; // 5. Report the predictions. println!("bimodal_ke compiled with runtime JIT"); println!("{:<6} {:>14}", "t", "prediction"); for prediction in predictions.predictions() { println!( "{:<6.1} {:>14.6}", prediction.time(), prediction.prediction() ); } Ok(()) } #[cfg(not(feature = "dsl"))] fn main() { eprintln!("Run with: cargo run --example dsl_runtime --features dsl"); std::process::exit(1); } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |